Files
mercury/tests/mmc_make/Mmakefile
Zoltan Somogyi 7d05201c2b Fix some problems with bootchecks.
These caused the tests in the mmc_make directory to be executed even
when they shouldn't have been, because the bootcheck did not specify
the --use-subdirs option. The root cause was probably the existence
of unintended Mercury directories, since this would cause mmake
to set MMAKE_USE_SUBDIRS to yes even without --use-subdirs.

tests/invalid/Mmakefile:
    Clean up the Mercury directory created by a test case here.

tests/mmc_make/Mmakefile:
    Clean up the Mercury directory created by all the test cases here.

    Make a rule more robust.

    Add a note about a currently unenabled test case.

tests/mmc_make/Mmakefile:
tests/valid_make_int/Mmakefile:
    Test for --use-subdirs being enabled via the new variable
    set by tools/bootcheck.

tools/bootcheck:
    Record the value of --use subdirs in a variable, TESTS_USE_SUBDIRS,
    that mmake does not know about and therefore will not touch.

    Fix three unrelated issues that came up in bootchecks for testing
    the above diff. They all involve the same small piece of code
    whose job is to clean up .data and .procrep files left by bootchecks
    in deep profiling grades.

    - One issue was the lack of an update for the somewhat-recent change
      in the naming of deep profiling data files;

    - another was the lack of required parentheses on the find command line;

    - and the third was the lack of protection for version-controlled files
      that we do NOT want to delete.
2025-03-28 11:17:06 +11:00

117 lines
3.5 KiB
Makefile

#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
TESTS_DIR = ..
THIS_DIR = mmc_make
MAYBE_J1 =
#-----------------------------------------------------------------------------#
MMAKE_USE_MMC_MAKE=yes
PROGS0 = \
bug489 \
complex_test \
hello \
include_file \
include_file2 \
linkage_test \
rebuild
ifeq "$(filter csharp% java%,$(GRADE))" ""
# XXX Why isn't build_object listed here?
C_ONLY_PROGS = \
factt
else
C_ONLY_PROGS =
endif
# The tests in this directory work only if the workspace was compiled
# with `--use-subdirs'. We test for this by checking the value of
# TESTS_USE_SUBDIRS, which tools/bootcheck sets to the same value
# it sets MMAKE_USE_SUBDIRS. The reason why we don't check the value
# of MMAKE_USE_SUBDIRS is that mmake itself, through scripts/mmake.in,
# can override the initial value of MMAKE_USE_SUBDIRS if it sees a Mercury
# directory, and we seem to have some test actions that create such
# directories. Some such actions, such as the ones in this directory,
# are *meant* to create Mercury directories, but some others may create them
# even though they shouldn't.
ifeq ($(TESTS_USE_SUBDIRS),yes)
PROGS = $(PROGS0) $(C_ONLY_PROGS)
else
PROGS =
endif
TESTS = $(sort $(PROGS))
include ../Mmake.common
%.runtest: %.res ;
Mercury.modules: $(wildcard *.m)
$(MC) -f $(wildcard *.m)
bug489.log: Mercury.modules
complex_test.log: install_libs
# Check that included files are identified as dependencies of the target code.
# sleep 1 is required because mmc --make timestamps are not granular enough.
include_file2.runtest: include_file
sleep 1 && touch inc/code.c inc/code.java inc/code.cs
$(MCM) --verbose-make include_file > include_file2.err 2>&1
! grep -qi 'error' include_file2.err && \
grep '^Making Mercury/.*/include_file[.]' include_file2.err
linkage_test.log: install_libs_linkage_test2
# Just test that the executable is rebuilt.
rebuild.runtest:
$(MCM) --rebuild rebuild
$(MCM) --rebuild --verbose-make rebuild > rebuild.err2 2>&1
! grep -qi 'error' rebuild.err2 && \
grep '^Making rebuild\($$\|\.\)' rebuild.err2
# The compiler used to fail when invoked as `mmc --make build_object.o'.
build_object.runtest: build_object.o
# Check that no errors occur while reading back the .module_dep file on the
# second run.
factt.runtest:
$(MCM) --make factt
$(MCM) --make factt >factt.err2 2>&1
! grep -i 'Error' factt.err2
.PHONY: install_libs
install_libs: start_runtests_local
$(MMAKE) TESTS_FLAGS
( cd lib; \
$(MCM) --no-libgrade --install-prefix $(shell pwd)/install \
libcomplex_numbers.install ) \
|| touch complex_test.failed
.PHONY: install_libs_linkage_test2
install_libs_linkage_test2: start_runtests_local
$(MMAKE) TESTS_FLAGS
( cd lib; \
$(MCM) --no-libgrade --install-prefix $(shell pwd)/install \
liblinkage_test2.install --lib-linkage static ) \
|| touch linkage_test.failed
# Copy/symlink TESTS_FLAGS into the current directory for when
# we change into the `lib' subdirectory.
TESTS_FLAGS: ../TESTS_FLAGS
ln -s $< $@ || cp $< $@
realclean_local: realclean_mmc_make
realclean_mmc_make: TESTS_FLAGS
rm -rf install include_file2.err rebuild.err2 factt.err2
# ./TESTS_FLAGS is expected by the following line.
cd lib; $(MCM) complex_numbers.realclean linkage_test2.realclean
rm -f TESTS_FLAGS
rm -f Mercury.modules
rm -rf Mercury lib/Mercury
#-----------------------------------------------------------------------------#