[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 2/6] [ng] parallel-tests: do not exceed command lin
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 2/6] [ng] parallel-tests: do not exceed command line length limits |
Date: |
Sat, 21 Jul 2012 10:50:41 +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): Moved 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 <address@hidden>
---
Makefile.am | 1 -
lib/am/clean.am | 6 -----
lib/am/header-vars.am | 6 +++++
lib/am/parallel-tests.am | 58 ++++++++++++++++++++++++++++++++++------------
4 files changed, 49 insertions(+), 22 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 290d5f4..54de62f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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 \
diff --git a/lib/am/clean.am b/lib/am/clean.am
index bc11bc4..aa463e5 100644
--- a/lib/am/clean.am
+++ b/lib/am/clean.am
@@ -14,12 +14,6 @@
## 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)
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 0549eaa..6fe0212 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -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@
diff --git a/lib/am/parallel-tests.am b/lib/am/parallel-tests.am
index 83b90d5..5544b1c 100644
--- a/lib/am/parallel-tests.am
+++ b/lib/am/parallel-tests.am
@@ -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
--
1.7.10.4
[Automake-NG] [PATCH 3/6] [ng] check: use awk rather than grep+xargs to count test results, Stefano Lattarini, 2012/07/21
[Automake-NG] [PATCH 4/6] [ng] check: refactor for less duplication and better performances, Stefano Lattarini, 2012/07/21
[Automake-NG] [PATCH 5/6] [ng] coverage: recheck with many failed tests, Stefano Lattarini, 2012/07/21