]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] parallel-tests: do not exceed command line length limits
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 20 Jul 2012 10:28:46 +0000 (12:28 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 22 Jul 2012 08:09:57 +0000 (10:09 +0200)
Fixes automake bug#7868.

Two things worth noting:

 + a "make recheck" issued after a huge number of tests have failed
   can still hit command-line length issues;

 + the check-recipes now contain (first among the Automake-generated
   recipes) a use of the 'xargs' utility.

These issues will likely be tackled by later patches.

* Makefile.am (XFAIL_TESTS): Remove 't/parallel-tests-many.sh'.
* lib/am/clean.am (.am.clean-cmd.f, .am.clean-cmd.d, .am.rm-f,
.am.rm-rf): Move their definitions ...
* lib/am/header-vars.am: ... here, because we need to use them ...
* lib/am/parallel-tests.am: ... here as well.
(am.test-harness.workdir, am.setup-test-harness-workdir,
am.test-harness.append-to-list-of-bases): New internal variables.
Use them to avoid hitting command-line length limits ...
($(TEST_SUITE_LOG), recheck): ... in this rules ...
(am__remove_if_not_lazy_check): ... and in the shell code defined
by this internal variable.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Makefile.am
lib/am/clean.am
lib/am/header-vars.am
lib/am/parallel-tests.am

index 290d5f42363348f7a6606106e485cce9a3be85f1..54de62fb9e20f6c7509afbf95069f36eb6391798 100644 (file)
@@ -350,7 +350,6 @@ XFAIL_TESTS = \
   t/interp3.sh \
   t/java-nobase.sh \
   t/objext-pr10128.sh \
-  t/parallel-tests-many.sh \
   t/pr8365-remake-timing.sh \
   t/remake-am-pr10111.sh \
   t/remake-m4-pr10111.sh \
index bc11bc4c7c3543c34365ffbb465163fd8f638f84..aa463e579070233fd095a5cdbb6d452e8d4edb9c 100644 (file)
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-.am.rm-f = $(if $(strip $1),rm -f $(strip $1)$(am__newline))
-.am.rm-rf = $(if $(strip $1),rm -rf $(strip $1)$(am__newline))
-
-.am.clean-cmd.f = $(call am.xargs-map,.am.rm-f,$1)
-.am.clean-cmd.d = $(call am.xargs-map,.am.rm-rf,$1)
-
 am__mostlyclean_files += $(MOSTLYCLEANFILES)
 am__clean_files       += $(CLEANFILES)
 am__distclean_files   += $(DISTCLEANFILES)
index 0549eaa191da3d2cc1c6e70f2d6ef53a5ba4d692..6fe0212d7278af2cd3952c37e6d8256250e8c107 100644 (file)
@@ -294,6 +294,12 @@ $(if $2,$(strip \
   )$(if $($0.counter),$(call $1,$(strip $($0.partial-args)))))
 endef
 
+.am.rm-f = $(if $(strip $1),rm -f $(strip $1)$(am__newline))
+.am.rm-rf = $(if $(strip $1),rm -rf $(strip $1)$(am__newline))
+
+.am.clean-cmd.f = $(call am.xargs-map,.am.rm-f,$1)
+.am.clean-cmd.d = $(call am.xargs-map,.am.rm-rf,$1)
+
 ## Some derived variables that have been found to be useful.
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
index 83b90d5114f13ada82c7a785c5f00a11b18bdd09..5544b1ce6732ac55ad727f5c252a8070d1fcfd0a 100644 (file)
@@ -261,23 +261,49 @@ am__mostlyclean_files += $(am__test_results) $(am__test_logs)
 # $(TEST_LOGS) is a published interface.
 TEST_LOGS = $(am__test_logs)
 
+am.test-harness.workdir = $(am__dir)/test-harness
+
+am.test-harness.append-to-list-of-bases = \
+  @lst='$1'; for x in $$lst; do echo $$x; done \
+    >> $(am.test-harness.workdir)/bases$(am__newline)
+
+!define am.setup-test-harness-workdir
+!      @rm -rf $(am.test-harness.workdir)
+!      @$(MKDIR_P) $(am.test-harness.workdir)
+!      @touch $(am.test-harness.workdir)/bases
+!      $(call am.xargs-map,am.test-harness.append-to-list-of-bases, \
+!             $(am__test_bases))
+!      @workdir='$(am.test-harness.workdir)' \
+!        && sed 's/$$/.log/' $$workdir/bases > $$workdir/logs \
+!        && sed 's/$$/.trs/' $$workdir/bases > $$workdir/trs
+!endef
+
 $(TEST_SUITE_LOG): $(am__test_logs) $(am__test_results)
+       $(am.setup-test-harness-workdir)
        @$(am__sh_e_setup); $(am__tty_colors); \
        fatal () { echo "fatal: making $@: $$*" >&2; exit 1; }; \
-## Detect a possible circular dependency, and error out.
-       case ' $(strip $(am__test_logs)) ' in *' $(TEST_SUITE_LOG) '*) \
-         fatal "depends on itself (check TESTS content)";; \
-       esac; \
+       workdir='$(am.test-harness.workdir)'; \
+## Detect a possible circular dependency, and error out if it's found.
+       grep '^$(TEST_SUITE_LOG:.log=)$$' $$workdir/bases \
+         && fatal "depends on itself (check TESTS content)"; \
        ws='[   ]'; \
        count_result () \
        { \
-         r='$(strip $(am__test_results))'; \
-         r=`grep "^$$ws*:test-result:$$ws*$${1-}" $$r </dev/null`; \
+         if test -s $$workdir/trs; then \
+           r=`xargs grep "^$$ws*:test-result:$$ws*$${1-}" <$$workdir/trs`; \
+         else \
+           r=''; \
+         fi; \
 ## Catch I/O errors, and complain accordingly.
-         test $$? -le 1 || fatal "I/O error reading test results"; \
+## FIXME: temporarily disabled.
+         : || test $$? -le 1 || fatal "I/O error reading test results"; \
+## Must use 'echo', not 'printf', because the latter could be an external
+## program rather than a builtin even on decent shells (like NetBSD 5.1
+## /bin/ksh), which could cause command-line length limits to be hit.
+## That already happened in practice.
          case $$r in \
            "") echo 0;; \
-           * ) printf '%s\n' "$$r" | wc -l;; \
+           * ) echo "$$r" | wc -l;; \
          esac; \
        }; \
 ## Prepare data for the test suite summary.  These do not take into account
@@ -345,8 +371,7 @@ $(TEST_SUITE_LOG): $(am__test_logs) $(am__test_results)
          echo;                                                         \
          echo ".. contents:: :depth: 2";                               \
          echo;                                                         \
-         bases='$(am__test_bases)';                                    \
-         for b in $$bases; do echo $$b; done                           \
+         while read b; do echo $$b; done <$$workdir/bases              \
            | $(am__create_global_log);                                 \
        } >$(TEST_SUITE_LOG).tmp; then                                  \
          mv -f $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                \
@@ -386,9 +411,7 @@ am__mostlyclean_files += $(TEST_SUITE_LOG)
 ## ------------------------------------------ ##
 
 am__remove_if_not_lazy_check = \
-## Expand the given list only once, to avoid exceeding line length limits.
-  $(if $(filter yes,$(AM_LAZY_CHECK)),, \
-       list='$(strip $(1))'; test -z "$$list" || rm -f $$list)
+  $(if $(filter yes,$(AM_LAZY_CHECK)),,$(call .am.clean-cmd.f,$1))
 
 check-TESTS:
        @$(call am__remove_if_not_lazy_check,$(am__test_results))
@@ -407,16 +430,21 @@ check-TESTS:
 ## 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%
+       +$(am.setup-test-harness-workdir)
 ## 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)
-       @bases='$(am__test_bases)'; \
 ## 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 \
+       @bases=`while read b; do echo $$b; done \
+                 <$(am.test-harness.workdir)/bases \
                 | $(am__list_recheck_tests)` || exit 1; \
 ## Remove newlines and normalize whitespace.
        bases=`echo $$bases`; \
+## FIXME: This could still cause command line length limits to be exceeded.
+## But that could happen only if a huge number of tests had failed in the
+## previous run, in which case we could expect the user to run "make check"
+## for safeness.  So, is this limitation worth lifting or not?
        $(MAKE) $(TEST_SUITE_LOG) .am/doing-recheck=yes am__test_bases="$$bases"
 .PHONY: recheck