Files
mercury/tests/exceptions/Mmakefile
Zoltan Somogyi 1f45f91886 Make "mmake runtests" work again.
My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.

tests/Mmake.common:
    Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
    defined it as such, I overlooked the fact that tests/Mmakefile itself
    defined it ".", referring to the same directory from a different starting
    point. Document this easily-overlooked fact.

    Rename the old runtests target, which after afe2887 runs the tests
    in a single directory, as runtests_dir, to leave the target name
    "runtests" itself free for tests/Mmakefile to use.

tests/Mmakefile:
    Define "TESTS_DIR = .", and add a target "runtests" which invokes
    "mmake runtests_dir" in each test directory.

tools/bootcheck:
    Invoke "mmake runtests_dir" instead of "mmake runtests" in each
    test directory.

    Initialize a variable just before it is used.

tests/*/Mmakefile:
    Add back the definition "TESTS_DIR = .."
2020-06-10 01:05:15 +10:00

74 lines
2.4 KiB
Makefile

#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
# Copyright (C) 1997-2000 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
#
# These rules define the main targets: depend, all, check.
#
TESTS_DIR = ..
THIS_DIR = exceptions
MAYBE_J1 =
#-----------------------------------------------------------------------------#
EXCEPTION_PROGS = \
test_exceptions \
test_exceptions_func \
test_try_all \
test_uncaught_exception \
tricky_try_store
# XXX the following tests are not enabled because we do not pass them yet:
# looptest.m
# (fails in debugging grades, because debugging breaks
# tail recursion optimization)
# test_memo.m test_loop_check.m
# (those two tests test the combination of
# tabling and exceptions).
#
# Also currently the compiler has a bug where it generates
# static ground terms even for things with `di' modes;
# tricky_try_store.m contains a work-around for that,
# which should be deleted once that bug is fixed.
# Deep profiling grades cannot yet handle catching exceptions, either
# explicitly or implicitly by the runtime system.
ifneq "$(findstring profdeep,$(GRADE))" ""
PROGS=
else
PROGS=$(EXCEPTION_PROGS)
endif
TESTS = $(PROGS)
include ../Mmake.common
# Module-specific options should go in Mercury.options so they
# can be found by `mmc --make'.
include Mercury.options
%.runtest: %.res ;
#-----------------------------------------------------------------------------#
# test_uncaught_exception is *supposed* to return an error exit status.
# We also need to pipe the output through sed to avoid hard-coding
# dependencies on particular line numbers in the standard library source code.
# We also filter out the stack trace in the java grade in order to avoid
# hard-coding dependencies on the Java runtime / generated code.
test_uncaught_exception.out: test_uncaught_exception
if ./$< > $@.tmp 2>&1; then \
grep . $@.tmp; \
exit 1; \
else \
sed -e '/pred exception/s/exception.m:[0-9]*/exception.m:NNNN/g' \
< $@.tmp | grep -v "jmercury\." > $@ ; \
rm -f $@.tmp; \
fi
#-----------------------------------------------------------------------------#