Files
mercury/tests/Mmakefile
Zoltan Somogyi be3f9443b1 Simplify the setup of mdbrc for tests.
We used to set up *two* mdbrc files for use by test cases:
scripts/test_mdbrc, and tests/mdbrc. Tools/bootcheck said
the tests should use the former, while tests/Mmake.common
said they should use the latter. This diff deletes the latter,
and uniformly uses the former.

The setup code was also scattered, with parts being done by
the configure script, and part being done by tools/bootcheck.
Move it all to scripts/Mmakefile, since that is the natural
place to put code to build scripts/test_mdbrc.

Mmakefile:
    Fix the action for cleaning up the tests directory.
    This started out as the reason for this whole change.
    As it happens, a *working* action for cleaning up the tests
    broke things, because it deleted an autoconfigured file
    (tests/mdbrc) that there was no rule for rebuilding.
    This issue is what required the rest of this diff.

    When doing "mmake clean/realclean", clean the extras as well.

configure.ac:
    Delete the code creating tests/mdbrc.in.

scripts/Mmakefile:
    Add a rule to build test_mdbrc, as mentioned above.

tests/Mmake.common:
    Switch to using scripts/test_mdbrc in test cases
    run under mdb.

    Mark the rules that clean up mdbrc and mdbrc.in
    as obsolete, since we will now stop creating those files.

tools/bootcheck:
    Delete the code that used to build tests/mdbrc. Instead,
    rebuild scripts/test_mdbrc (in case the workspace was moved),
    and use that.

tests/Mmakefile:
    When cleaning the tests directory, clean its subdirectories
    (since the top level directory does not have much clean).
2020-10-04 23:00:29 +11:00

123 lines
2.4 KiB
Makefile

#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
THIS_DIR=tests
PROGS=
TESTS=
# If you modify this, modify all_test_dirs in tools/bootcheck as well.
SUBDIRS = \
accumulator \
analysis \
analysis_ctgc \
analysis_excp \
analysis_external \
analysis_sharing \
analysis_table \
analysis_trail \
analysis_unused_args \
benchmarks \
debugger \
declarative_debugger \
dppd \
exceptions \
feedback \
general \
grade_subdirs \
hard_coded \
invalid \
invalid_make_int \
invalid_options_file \
invalid_purity \
invalid_submodules \
misc_tests \
mmc_make \
options_file \
par_conj \
purity \
recompilation \
string_format \
structure_reuse \
submodules \
tabling \
term \
trailing \
typeclasses \
valid \
valid_make_int \
valid_seq \
warnings
NOT_YET_READY_SUBDIRS = \
stm
TESTS_DIR = .
include Mmake.common
.PHONY: check
check: runtests
.PHONY: runtests
runtests:
+@if mmake -k runtests_subdirs; then \
rm -f $(ERROR_OUTPUT_FILE); \
else \
for subdir in $(SUBDIRS); do \
if test -f $$subdir/$(ERROR_OUTPUT_FILE); then \
cat $$subdir/$(ERROR_OUTPUT_FILE) \
>> $(ERROR_OUTPUT_FILE); \
fi; \
if test -f $$subdir/FAILED_TESTS; then \
sed "s@^@$$subdir/@" $$subdir/FAILED_TESTS \
>> FAILED_TESTS; \
fi; \
done; \
echo SOME TESTS FAILED: see FAILED_TESTS and $(ERROR_OUTPUT_FILE); \
exit 1; \
fi
RUNTESTS_IN_SUBDIRS=$(SUBDIRS:%=runtests_in_%)
.PHONY: runtests_subdirs
runtests_subdirs: $(RUNTESTS_IN_SUBDIRS)
.PHONY: runtests_in_subdirs
$(RUNTESTS_IN_SUBDIRS): runtests_in_%:
+if test -d $* ; then \
cd $* && mmake runtests_dir ; \
else \
echo Could not run tests in directory $* ; \
echo Could not run tests in directory $* >> NOMAKE_DIRS ; \
fi
#-----------------------------------------------------------------------------#
realclean: realclean_subdirs
realclean_subdirs:
+succeeded=true; \
for dir in $(SUBDIRS); do \
(cd $$dir && mmake realclean) || succeeded=false; \
done
case $$succeeded in \
false) \
exit 1 \
;; \
esac
clean: clean_subdirs
clean_subdirs:
+succeeded=true; \
for dir in $(SUBDIRS); do \
(cd $$dir && mmake clean) || succeeded=false; \
done; \
case $$succeeded in \
false) \
exit 1 \
;; \
esac
#-----------------------------------------------------------------------------#