Merge branch 'maint'
[platform/upstream/automake.git] / lib / am / check.am
index ad970ad..f085f8e 100644 (file)
@@ -17,7 +17,7 @@
 am__tty_colors_dummy = \
   mgn= red= grn= lgn= blu= brg= std=; \
   am__color_tests=no
-if %?COLOR%
+
 am__tty_colors = { \
   $(am__tty_colors_dummy); \
   if test "X$(AM_COLOR_TESTS)" = Xno; then \
@@ -40,9 +40,6 @@ am__tty_colors = { \
     std='\e[m'; \
   fi; \
 }
-else !%?COLOR%
-am__tty_colors = $(am__tty_colors_dummy)
-endif !%?COLOR%
 
 .PHONY: check-TESTS
 
@@ -221,7 +218,7 @@ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
 # '$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,
 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
 # since that might cause problem with VPATH rewrites for suffix-less tests.
-# See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
 am__set_TESTS_bases = \
   bases='$(TEST_LOGS)'; \
   bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
@@ -240,6 +237,12 @@ am__set_TESTS_bases = \
        rm -f $< $@
        $(MAKE) $(AM_MAKEFLAGS) $<
 
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# exand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+       @:
+
 $(TEST_SUITE_LOG): $(TEST_LOGS)
        @$(am__set_TESTS_bases); \
 ## Helper shell function, tells whether a path refers to an existing,
@@ -396,21 +399,10 @@ RECHECK_LOGS = $(TEST_LOGS)
 ## Running all tests, or rechecking failures. ##
 ## ------------------------------------------ ##
 
-check-TESTS recheck:
-## If we are running "make recheck", it's not the user which can decide
-## which tests to consider for re-execution, so we must ignore the value
-## of $(RECHECK_LOGS).
-## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding
-## line length limits.
-       @if test $@ != recheck; then \
-          list='$(RECHECK_LOGS)'; \
-          test -z "$$list" || rm -f $$list; \
-        fi
-       @if test $@ != recheck; then \
-          list='$(RECHECK_LOGS:.log=.trs)'; \
-          test -z "$$list" || rm -f $$list; \
-        fi
-## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
+check-TESTS:
+       @list='$(RECHECK_LOGS)';           test -z "$$list" || rm -f $$list
+       @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
 ## or a prior run plus reruns all happen within the same timestamp (can
 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
@@ -418,35 +410,51 @@ check-TESTS recheck:
 ## cannot use '$?' to compute the set of lazily rerun tests, lest
 ## we rely on .PHONY to work portably.
        @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
-       @$(am__set_TESTS_bases); \
-       if test $@ = recheck; then \
-## If running a "make recheck", we must only consider tests that had an
-## unexpected outcome (FAIL or XPASS) in the earlier run.
-         bases=`for i in $$bases; do echo $$i; done \
-                  | $(am__list_recheck_tests)` || exit 1; \
-       fi; \
+       @set +e; $(am__set_TESTS_bases); \
        log_list=`for i in $$bases; do echo $$i.log; done`; \
        trs_list=`for i in $$bases; do echo $$i.trs; done`; \
-## Remove newlines and normalize whitespace, being careful to avoid extra
-## whitespace in the definition of $log_list, since its value will be
-## passed to the recursive make invocation below through the TEST_LOGS
-## macro, and leading/trailing white space in a make macro definition can
-## be problematic.  In this particular case, trailing white space is known
-## to have caused segmentation faults on Solaris 10 XPG4 make:
+## Remove newlines and normalize whitespace.  Trailing (and possibly
+## leading) whitespace is known to cause segmentation faults on
+## Solaris 10 XPG4 make.
        log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
-## Under "make recheck", remove the .log and .trs files associated
-## with the files to recheck, so that those will be rerun by the
-## "make test-suite.log" recursive invocation below.  But use a proper
-## hack to avoid extra files removal when running under "make -n".
-       if test $@ != recheck || $(am__make_dryrun); then :; else \
-         test -z "$$log_list" || rm -f $$log_list; \
-         test -z "$$trs_list" || rm -f $$trs_list; \
-       fi; \
-       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+## Be sure to exit with the proper exit status (automake bug#9245).  See
+## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
+       exit $$?;
 
 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
 ## It must also depend on the 'all' target.  See automake bug#11252.
 recheck: all %CHECK_DEPS%
+## See comments above in the check-TESTS recipe for why remove
+## $(TEST_SUITE_LOG) here.
+       @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+       @set +e; $(am__set_TESTS_bases); \
+## We must only consider tests that had an unexpected outcome (FAIL
+## or XPASS) in the earlier run.
+       bases=`for i in $$bases; do echo $$i; done \
+                | $(am__list_recheck_tests)` || exit 1; \
+       log_list=`for i in $$bases; do echo $$i.log; done`; \
+## Remove newlines and normalize whitespace.  Trailing (and possibly
+## leading) whitespace is known to cause segmentation faults on
+## Solaris 10 XPG4 make.
+       log_list=`echo $$log_list`; \
+## Move the '.log' and '.trs' files associated with the tests to be
+## re-run out of the way, so that those tests will be re-run by the
+## "make test-suite.log" recursive invocation below.
+## Two tricky requirements:
+##   - we must avoid extra files removal when running under "make -n";
+##   - in case the test is a compiled program whose compilation fails,
+##     we must ensure that any '.log' and '.trs' file referring to such
+##     test are preserved, so that future "make recheck" invocations
+##     will still try to re-compile and re-run it (automake bug#11791).
+## The tricky recursive make invocation below should cater to such
+## requirements.
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+               am__force_recheck=am--force-recheck \
+               TEST_LOGS="$$log_list"; \
+## Be sure to exit with the proper exit status (automake bug#9245).  See
+## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
+       exit $$?
 
 AM_RECURSIVE_TARGETS += check recheck