automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] {maint} recheck: behave better with non-GNU make


From: Stefano Lattarini
Subject: [PATCH 3/4] {maint} recheck: behave better with non-GNU make
Date: Fri, 13 Jan 2012 22:46:08 +0100

* automake.in (handle_tests): Also substitute '%CHECK_DEPS%' with
the value of the '@check' array, containing the list of early
test dependencies like '$(check_SCRIPTS)', $(check_PROGRAMS)',
etc.
* lib/am/check.am (recheck): Explicitly depend on '%CHECK_DEPS%'.
(check, recheck): Unify the implementation of their recipes, with
different code paths taken depending on the name of the target.
This makes the implementation of "recheck" less brittle in the
process (especially when non-GNU make and AM_MAKEFLAGS overriding
are involved).
* lib/am/check-html.am (check-html, recheck-html): Likewise.
* tests/check.test: Adjust to avoid spurious failure.
* tests/parallel-tests2.test: Improve coverage.
---
 automake.in                |    4 ++-
 lib/am/check-html.am       |   29 +++++------------------
 lib/am/check.am            |   54 +++++++++++++++++++++----------------------
 tests/check.test           |    4 +-
 tests/parallel-tests2.test |   15 ++++++++++++
 5 files changed, 52 insertions(+), 54 deletions(-)

diff --git a/automake.in b/automake.in
index 96376d0..7ce825a 100644
--- a/automake.in
+++ b/automake.in
@@ -4958,9 +4958,11 @@ sub handle_tests
   if (var ('TESTS'))
     {
       push (@check_tests, 'check-TESTS');
+      my $check_deps = "@check";
       $output_rules .= &file_contents ('check', new Automake::Location,
                                       COLOR => !! option 'color-tests',
-                                      PARALLEL_TESTS => !! option 
'parallel-tests');
+                                      PARALLEL_TESTS => !! option 
'parallel-tests',
+                                       CHECK_DEPS => $check_deps);
 
       # Tests that are known programs should have $(EXEEXT) appended.
       # For matching purposes, we need to adjust XFAIL_TESTS as well.
diff --git a/lib/am/check-html.am b/lib/am/check-html.am
index 7cbdf8a..13f0a47 100644
--- a/lib/am/check-html.am
+++ b/lib/am/check-html.am
@@ -47,31 +47,14 @@ am--mostlyclean-test-html:
 # Beware of concurrent executions.  Run "check" not "check-TESTS", as
 # check-SCRIPTS and other dependencies are rebuilt by the former only.
 # And expect check to fail.
-check-html:
-       @if $(MAKE) $(AM_MAKEFLAGS) check; then                 \
-         rv=0; else rv=$$?;                                    \
-       fi;                                                     \
-       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4;   \
+check-html recheck-html:
+       @target=`echo $@ | sed 's/-html$$//'`; \
+       rv=0; $(MAKE) $(AM_MAKEFLAGS) $$target || rv=$$?; \
+## The nullification of $(TEST_LOGS) is required to ensure that
+## "make recheck-html" do not try to uselessly re-run tests.
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) TEST_LOGS= || exit 4; \
        exit $$rv
 
-## Rerun all FAILed or XPASSed tests.
-recheck-html:
-       @list='' list2='$(TEST_LOGS)'; \
-       for f in $$list2; do \
-         test -f $$f || continue; \
-         if test -r $$f && read line < $$f; then \
-           case $$line in FAIL*|XPASS*) : ;; *) continue;; esac; \
-         fi; \
-## Be careful to avoid extra whitespace in the definition of $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 was known to cause a segmentation fault on Solaris 10 XPG4 make:
-## <http://lists.gnu.org/archive/html/bug-automake/2010-08/msg00004.html>
-         if test -z "$$list"; then list=$$f; else list="$$list $$f"; fi; \
-       done; \
-       $(MAKE) $(AM_MAKEFLAGS) check-html AM_MAKEFLAGS='$(AM_MAKEFLAGS) 
TEST_LOGS="'"$$list"'"'
-
 AM_RECURSIVE_TARGETS += check-html recheck-html
 
 .PHONY: check-html recheck-html
diff --git a/lib/am/check.am b/lib/am/check.am
index bca7763..47561ae 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -233,15 +233,18 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 
 RECHECK_LOGS = $(TEST_LOGS)
 
-# Run all the tests.
-check-TESTS:
+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).
+       @if test $@ != recheck; then \
 ## Expand $(RECHECK_LOGS) only once, to avoid exceeding line length limits.
-       @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+          list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list; \
+        fi
 ## 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.
+## 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.
 ## OTOH, this means that, in the rule for `$(TEST_SUITE_LOG)', we
 ## cannot use `$?' to compute the set of lazily rerun tests, lest
 ## we rely on .PHONY to work portably.
@@ -251,25 +254,13 @@ check-TESTS:
 ## 3.80 to erroneously expand $(TESTS_LOGS) to `foo.log .log'.
 ## Work around this bug.
          test .log = $$f && continue; \
-## Be careful to avoid extra whitespace in the definition of $list.  See
-## comments in `recheck' below for why this might be useful.
-         if test -z "$$list"; then list=$$f; else list="$$list $$f"; fi; \
-       done; \
-       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
-
-AM_RECURSIVE_TARGETS += check
-
-## -------------------- ##
-## Rechecking failures. ##
-## -------------------- ##
-
-## Rerun all FAILed or XPASSed tests.
-recheck:
-       @list='' list2='$(TEST_LOGS)'; \
-       for f in $$list2; do \
-         test -f $$f || continue; \
-         if test -r $$f && read line < $$f; then \
-           case $$line in FAIL*|XPASS*) : ;; *) continue;; esac; \
+## If running a "make recheck", we must only consider tests that had
+## an unexpected outcome (FAIL or XPASS) in the earlier run.
+         if test $@ = recheck; then \
+           test -f $$f || continue; \
+           if test -r $$f && read line < $$f; then \
+             case $$line in FAIL*|XPASS*) : ;; *) continue;; esac; \
+           fi; \
          fi; \
 ## Be careful to avoid extra whitespace in the definition of $list, since
 ## its value will be passed to the recursive make invocation below through
@@ -279,13 +270,20 @@ recheck:
 ## <http://lists.gnu.org/archive/html/bug-automake/2010-08/msg00004.html>
          if test -z "$$list"; then list=$$f; else list="$$list $$f"; fi; \
        done; \
-       $(MAKE) $(AM_MAKEFLAGS) check AM_MAKEFLAGS='$(AM_MAKEFLAGS) 
TEST_LOGS="'"$$list"'"'
+## Under "make recheck", remove the logs of the files to recheck, so that
+## those will be rerun by the "make test-suite.log" recursive invocation
+## below.
+       test $@ != recheck || test -z "$$list" || rm -f $$list || exit 1; \
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
+
+## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
+recheck: %CHECK_DEPS%
+
+AM_RECURSIVE_TARGETS += check recheck
 
 .PHONY: recheck
 .MAKE: recheck
 
-AM_RECURSIVE_TARGETS += recheck
-
 ## ----------------------------------------------- ##
 ## Produce HTML.  To be removed in automake 1.12.  ##
 ## ----------------------------------------------- ##
diff --git a/tests/check.test b/tests/check.test
index 0c258c5..3001228 100755
--- a/tests/check.test
+++ b/tests/check.test
@@ -29,8 +29,8 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '^check-TESTS:' Makefile.in
-grep '^check-DEJAGNU' Makefile.in && Exit 1
+grep 'check-TESTS.*:' Makefile.in
+grep 'check-DEJAGNU' Makefile.in && Exit 1
 
 # check-TESTS is phony.
 sed -n '/^\.PHONY:/,/^$/p' Makefile.in | grep check-TESTS
diff --git a/tests/parallel-tests2.test b/tests/parallel-tests2.test
index aa2afef..78d5a76 100755
--- a/tests/parallel-tests2.test
+++ b/tests/parallel-tests2.test
@@ -98,12 +98,27 @@ test ! -f mylog.html
 
 # check-html and recheck-html should cause check_SCRIPTS to be created,
 # and recheck-html should rerun no tests if check has not been run.
+
 $MAKE clean
+test ! -f mylog.html
 env TESTS=foo.test $MAKE -e check-html
 test -f bla
+test -f foo.log
+test ! -f bar.log
+test ! -f baz.log
+
 $MAKE clean
 env TESTS=foo.test $MAKE -e recheck-html
 test -f bla
 test ! -f foo.log
 test -f mylog.html
+
+$MAKE clean
+$MAKE recheck-html
+test -f bla
+test ! -f foo.log
+test ! -f bar.log
+test ! -f baz.log
+test -f mylog.html
+
 :
-- 
1.7.7.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]