Files
mercury/tests/string_format/Mmakefile
Zoltan Somogyi 8a764392d9 Avoid warnings from make in test directories.
tests/Mmake.common:
    Don't invoke any actions in the clean_local and realclean_local
    targets, since if using mmc --make, the builtin mmake rules
    have actions for those targets as well, and make can't handle
    more than one action for a target having actions. Replace those
    actions with dependencies on other, unique targets that have
    the actions instead.

tests/*/Mmakefile:
    Avoid actions in clean_local and realclean_local targets the same way.

    Sort the test names in some directories that didn't already do so.

    Delete some obsolete comments.

    Fix style.

tests/valid/Mmake.valid.common:
    As for the Mmakefiles above, and also move the definition of a make
    variable before it is needed.
2015-09-08 05:57:53 +10:00

127 lines
4.0 KiB
Makefile

#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
THIS_DIR = string_format
SUBDIRS =
TESTS_DIR = ..
MAYBE_J1 = -j1
#-----------------------------------------------------------------------------#
# Any program added here should also be added to the `.cvsignore' file.
STRING_FORMAT_PROGS = \
string_format_c \
string_format_d \
string_format_e \
string_format_f \
string_format_g \
string_format_o \
string_format_s \
string_format_u \
string_format_x
# The tests don't work in the *.agc grades, because I think they
# take too long to finish and the CPU time limit is breached.
ifneq "$(findstring .agc,$(GRADE))" ""
PROGS0 =
else
PROGS0 = $(STRING_FORMAT_PROGS)
endif
# On solaris 5.{7,8} string_format_o fails because of a buggy
# sprintf implementation.
SOLARIS_FAILURES = string_format_o
# On Dec OSF 5.1 the floating point tests fail because
# the denormal floats aren't being printed correctly.
OSF1_FAILURES = string_format_e string_format_f string_format_g
UNAME := $(shell uname -r -s)
ifeq "$(filter-out SunOS 5.7 5.8,$(UNAME))" ""
PROGS = $(filter-out $(SOLARIS_FAILURES),$(PROGS0))
else
ifneq "$(findstring OSF1 V5.1,$(UNAME))" ""
PROGS = $(filter-out $(OSF1_FAILURES),$(PROGS0))
else
PROGS = $(PROGS0)
endif
endif
TESTS = $(sort $(PROGS))
include $(TESTS_DIR)/Mmake.common
# Module-specific options should go in Mercury.options so they can be found
# by `mmc --make'.
include Mercury.options
%.runtest: %.res ;
#
# This is adapted from the rule in ../../Mmake.common. The
# difference is that we only display the last 20 lines of the output
# file if the file fails, due to the size of the output file.
#
%.out: %
{ [ -f $*.inp ] && cat $*.inp; } | ./$< > $@ 2>&1 || \
{ grep . $@ /dev/null | tail -n 20; exit 1; }
#
# This is adapted from the rule in ../../Mmake.common. The only
# differences are that we only cat the first 50 lines to stdout, as
# generally it is quite big and that we sort both the output and the
# expected output before the comparison, as the IL and C backends use
# a different ordering for lexical comparisons. The reason for sorting
# the expected output as well is to allow for different behaviour in
# different versions of sort.
#
%.res: %.exp %.out
@echo "Comparing $*.sorted_out with $*.sorted_exp*,"
@echo " results in $@"
@-rm -f $@ $*.res[1-5]
@sort $*.out > $*.sorted_out
@sort $*.exp > $*.sorted_exp
@{ diff $(DIFF_OPTS) $*.sorted_exp $*.sorted_out > $*.res1 && \
echo "Matched $*.sorted_exp" && \
cp $*.res1 $@; } || \
{ test -f $*.exp2 && \
sort $*.exp2 > $*.sorted_exp2 &&\
diff $(DIFF_OPTS) $*.sorted_exp2 $*.sorted_out > $*.res2 && \
echo "Matched $*.sorted_exp2" && \
cp $*.res2 $@; } || \
{ test -f $*.exp3 && \
sort $*.exp3 > $*.sorted_exp3 && \
diff $(DIFF_OPTS) $*.sorted_exp3 $*.sorted_out > $*.res3 && \
echo "Matched $*.sorted_exp3" && \
cp $*.res3 $@; } || \
{ test -f $*.exp4 && \
sort $*.exp4 > $*.sorted_exp4 && \
diff $(DIFF_OPTS) $*.sorted_exp4 $*.sorted_out > $*.res4 && \
echo "Matched $*.sorted_exp4" && \
cp $*.res4 $@; } || \
{ test -f $*.exp5 && \
sort $*.exp5 > $*.sorted_exp5 && \
diff $(DIFF_OPTS) $*.sorted_exp5 $*.sorted_out > $*.res5 && \
echo "Matched $*.sorted_exp5" && \
cp $*.res5 $@; } || \
{ shortest=`wc -l $*.res[1-5] | grep -v total | sort -n | \
head -1 | awk '{ print $$2; }' `; \
echo "** $*.sorted_out did not match the expected output"; \
echo "** (closest match was $$shortest)"; \
echo "** The diff is located in $@"; \
cp $$shortest $@; \
cat $$shortest | head -n 50; \
exit 1; }
#-----------------------------------------------------------------------------#
realclean_local: clean_sorted_files
clean_local: clean_sorted_files
clean_sorted_files:
rm -f *.sorted_out *.sorted_exp*
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#