[m-rev.] for review: make the test suite work with MSYS2
Julien Fischer
jfischer at opturion.com
Mon Jun 12 03:38:34 AEST 2023
For review by anyone.
---------------------
Make the test suite work with MSYS2.
tools/bootcheck:
On MSYS2, translate paths written to .options and _FLAGS files into
Windows-style paths.
On MYS2, pass --strip-trailing-cr to diff.
Julien.
diff --git a/tools/bootcheck b/tools/bootcheck
index 9a6b606..c31f9ff 100755
--- a/tools/bootcheck
+++ b/tools/bootcheck
@@ -641,6 +641,31 @@ SED=${SED:-sed}
#-----------------------------------------------------------------------------#
+# Work out if we are running in one of the MSYS2 environments on Windows.
+# On these systems some tools, e.g. the shell and make, use POSIX style paths
+# overlaid on Windows file system, but the Mercury compiler uses Windows style
+# paths. There is some automatic translation done between the two, but we need
+# to ensure that paths put in .options or _FLAGS files are in the appropriate
+# format. For the MSYS2 environment, we also need to set some things up (e.g.
+# options to diff) for the test suite to work properly.
+case "${MSYSTEM}" in
+
+ MINGW64|MINGW32|UCRT64|CLANG64)
+ env_is_msys2=true
+ ;;
+
+ CLANGARM64|MSYS)
+ echo "bootchecking using MSYS2 environment ${MSYSTEM} is not supported."
+ exit 1
+ ;;
+
+ *)
+ env_is_msys2=false
+ ;;
+esac
+
+#-----------------------------------------------------------------------------#
+
# Turn off the debugger, since accidentally leaving it on will result
# in user interaction every time we invoke any version of the compiler
# that was compiled with tracing. This has happened to me accidentally
@@ -1995,7 +2020,12 @@ then
stage2_insert=""
fi
- WORKSPACE="${root}${stage2_insert}"
+ if "$env_is_msys2"
+ then
+ WORKSPACE=$(pwd -W "${root}${stage2_insert}")
+ else
+ WORKSPACE="${root}${stage2_insert}"
+ fi
export WORKSPACE
MMAKE_DIR="${root}${stage2_insert}/scripts"
@@ -2014,6 +2044,10 @@ if test -s "${HOME}"/.bootcheck_diff_opts
then
DIFF_OPTS=$(cat "${HOME}"/.bootcheck_diff_opts)
export DIFF_OPTS
+elif "$env_is_msys2"
+then
+ DIFF_OPTS=--strip-trailing-cr
+ export DIFF_OPTS
fi
test_status=0
@@ -2061,13 +2095,27 @@ then
cp "${root}"/doc/mdb_command_test.inp tests/debugger
- ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
- < tests/WS_FLAGS.ws \
- > tests/WS_FLAGS
+ if "$env_is_msys2"
+ then
+ # XXX Parameter expansion with pattern substitutions is a bash-ism
+ # that is not supported by POSIX sh. (It shouldn't matter here as
+ # bash is the default shell used by MSYS2 anyway.)
+ ${SED} -e "s:@WORKSPACE@:${WORKSPACE/:/\\:}:" \
+ < tests/WS_FLAGS.ws \
+ > tests/WS_FLAGS
+
+ ${SED} -e "s:@WORKSPACE@:${WORKSPACE/:/\\:}:" \
+ < tests/.mgnuc_copts.ws \
+ > tests/.mgnuc_copts
+ else
+ ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
+ < tests/WS_FLAGS.ws \
+ > tests/WS_FLAGS
- ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
- < tests/.mgnuc_copts.ws \
- > tests/.mgnuc_copts
+ ${SED} -e "s:@WORKSPACE@:${WORKSPACE}:" \
+ < tests/.mgnuc_copts.ws \
+ > tests/.mgnuc_copts
+ fi
# If you modify this, modify SUBDIRS in tests/Mmakefile as well.
all_test_dirs="
More information about the reviews
mailing list