Don't leave stray Mercury directories in tests.

tests/Mmake.common:
    Bootchecks in the csharp and java grades, which use mmc --make
    and --use-subdirs, have traditionally left all the Mercury directories
    they constructed in tests/*. These screwed up any subsequent bootchecks
    in other grades, because the mere presence of those directories
    told the compiler to put their results in there, which was not always
    what was wanted.

    Fix this by

    - deleting any Mercury directories before we start runtests in a test
      directory,

    - deleting any Mercury directories after runtests succeeds in a test
      directory, and

    - rename any Mercury directories after runtests fails in a test
      directory, to Mercury.failed.

    This last part allows any failures to be investigated and debugged,
    without interfering with later bootchecks. (Though those later bootchecks
    will delete any Mercury.failed directories, so they should be moved
    elsewhere first if they may be needed later.)

tools/bootcheck:
    Delete the temporary code that helped me track down this issue
    and to conform its fix.

    Fix too-long lines.
This commit is contained in:
Zoltan Somogyi
2025-07-13 17:32:44 +02:00
parent dc73319765
commit 372f41f867
2 changed files with 36 additions and 22 deletions

View File

@@ -360,6 +360,7 @@ start_runtests_local:
rm -f *.trans_opt *.trans_opt_date > /dev/null 2>&1; \
rm -f .mercury_trace_counts* > /dev/null 2>&1; \
rm -f .date* > /dev/null 2>&1; \
rm -rf Mercury > /dev/null 2>&1; \
fi
@> FAILED_TESTS
@@ -396,6 +397,7 @@ start_runtests_local:
TEST_LOGS = $(THIS_DIR_TESTS_TO_RUN:%=%.log)
runtests_local:
+@ \
/bin/rm -fr Mercury lib/Mercury > /dev/null 2>&1; \
mmake -k $(MAYBE_J1) $(TEST_LOGS); \
touch DUMMY.log; \
cat *.log > $(ERROR_OUTPUT_FILE); \
@@ -405,9 +407,18 @@ runtests_local:
echo cleaning up the directory after the tests; \
mmake $(RM_JFACTOR) realclean_local > /dev/null 2>&1; \
rm core > /dev/null 2>&1; \
/bin/rm -fr Mercury lib/Mercury > /dev/null 2>&1; \
touch CLEAN; \
else \
echo "FAILED tests in $(THIS_DIR) $(PARAMS_MSG)"; \
/bin/rm -fr Mercury.failed lib/Mercury.failed \
> /dev/null 2>&1; \
if test -d Mercury; then \
mv -f Mercury Mercury.failed; \
fi; \
if test -d lib/Mercury; then \
mv -f lib/Mercury lib/Mercury.failed; \
fi; \
exit 1; \
fi

View File

@@ -1063,12 +1063,14 @@ then
if test -f "${root}"/Mmake.stage.mdbcomp.params
then
/bin/rm -f mdbcomp/Mmake.mdbcomp.params
cp "${root}"/Mmake.stage.mdbcomp.params mdbcomp/Mmake.mdbcomp.params
cp "${root}"/Mmake.stage.mdbcomp.params \
mdbcomp/Mmake.mdbcomp.params
fi
if test -f "${root}"/Mmake.stage.browser.params
then
/bin/rm -f browser/Mmake.browser.params
cp "${root}"/Mmake.stage.browser.params browser/Mmake.browser.params
cp "${root}"/Mmake.stage.browser.params \
browser/Mmake.browser.params
fi
if test -f "${root}"/Mmake.stage.ssdb.params
then
@@ -1084,7 +1086,8 @@ then
if test -f "${root}"/Mmake.stage.deep.params
then
/bin/rm -f deep_profiler/Mmake.deep.params
cp "${root}"/Mmake.stage.deep.params deep_profiler/Mmake.deep.params
cp "${root}"/Mmake.stage.deep.params \
deep_profiler/Mmake.deep.params
fi
if test -f "${root}"/Mmake.stage.compiler.params
then
@@ -1095,12 +1098,14 @@ then
if test -f "${root}"/Mmake.stage.library.params
then
/bin/rm -f library/Mmake.library.params
cp "${root}"/Mmake.stage.library.params library/Mmake.library.params
cp "${root}"/Mmake.stage.library.params \
library/Mmake.library.params
fi
if test -f "${root}"/Mmake.stage.runtime.params
then
/bin/rm -f runtime/Mmake.runtime.params
cp "${root}"/Mmake.stage.runtime.params runtime/Mmake.runtime.params
cp "${root}"/Mmake.stage.runtime.params \
runtime/Mmake.runtime.params
fi
if test -f "${root}"/Mmake.stage.trace.params
then
@@ -1621,7 +1626,8 @@ EOF
mkdir deep_profiler
cd deep_profiler
${LN_S} "${root}"/deep_profiler/*.m .
cp "${root}"/deep_profiler/Mmake* "${root}"/deep_profiler/Mercury.options .
cp "${root}"/deep_profiler/Mmake* \
"${root}"/deep_profiler/Mercury.options .
cp "${root}"/deep_profiler/*_FLAGS.in .
cp "${root}"/deep_profiler/.mgnu* .
@@ -1629,7 +1635,8 @@ EOF
mkdir mfilterjavac
cd mfilterjavac
${LN_S} "${root}"/mfilterjavac/*.m .
cp "${root}"/mfilterjavac/Mmake* "${root}"/mfilterjavac/Mercury.options .
cp "${root}"/mfilterjavac/Mmake* \
"${root}"/mfilterjavac/Mercury.options .
cp "${root}"/mfilterjavac/*_FLAGS.in .
cp "${root}"/mfilterjavac/.mgnu* .
@@ -1641,7 +1648,8 @@ EOF
${LN_S} "${root}"/install-sh .
${LN_S} "${root}"/.*.in .
rm -f config*.log
cp "${root}"/${stage2dir}/Mmake* "${root}"/${stage2dir}/Mercury.options .
cp "${root}"/${stage2dir}/Mmake* \
"${root}"/${stage2dir}/Mercury.options .
cd "${root}"
# set -x
@@ -1925,11 +1933,11 @@ EOF
# files present in the stage 3 directory.
for file in ${stage3dir}/${dir}/${target_subdir}*.${target_ext}
do
# In the C# and Java grades, some modules have expected differences
# between the code generated for them in stage 2 and stage 3,
# due to stage 2 being (usually) generated by a 64 bit compiler,
# but stage 3 being generated by a compiler in which native
# integers are 32 bits.
# In the C# and Java grades, some modules have expected
# differences between the code generated for them
# in stage 2 and stage 3, due to stage 2 being (usually)
# generated by a 64 bit compiler, but stage 3 being generated
# by a compiler in which native integers are 32 bits.
compare_file=true
base_file=$(basename "${file}")
case "${grade}" in
@@ -2016,7 +2024,8 @@ EOF
esac
if ${compare_file}
then
diff -u "${stage2dir}/${dir}/${target_subdir}${base_file}" \
diff -u \
"${stage2dir}/${dir}/${target_subdir}${base_file}" \
"${file}" \
|| diff_status=1
fi
@@ -2360,13 +2369,6 @@ then
do
if test -d "${root}/tests/${testdir}"
then
# Temporary addition on 2025 mar 28, intended to
# track down any stray Mercury directories left
# unintentionally by test cases.
echo FIND BAD SUBDIRS
find ${root} -name Mercury
echo END FIND BAD SUBDIRS
cd "${root}/tests/${testdir}"
mmake ${mmake_opts} ${target_opt} ${jfactor} \
${test_grade_opt} ${test_log_opt} \
@@ -2518,7 +2520,8 @@ then
"${tests_dir}"/EXPECT_FAIL_TESTS
fi
sort "${tests_dir}"/EXPECT_FAIL_TESTS > "${tests_dir}"/EXPECT_FAIL_TESTS.sort
sort "${tests_dir}"/EXPECT_FAIL_TESTS \
> "${tests_dir}"/EXPECT_FAIL_TESTS.sort
mv "${tests_dir}"/EXPECT_FAIL_TESTS.sort "${tests_dir}"/EXPECT_FAIL_TESTS
sort "${tests_dir}"/FAIL_TESTS > "${tests_dir}"/FAIL_TESTS.sort