On 02/05/2012 10:05 PM, Stefano Lattarini wrote:
> On 02/05/2012 06:35 PM, Stefano Lattarini wrote:
>> On 01/23/2012 09:10 PM, Stefano Lattarini wrote:
>>> We define a new variable '$(am__make_dryrun)', that can be used
>>> in recipes to determine whether make is running in "dry mode" (as
>>> with "make -n") or not.  This is useful in rules that invoke make
>>> recursively, and are thus executed also with "make -n" -- either
>>> because they are declared as dependencies to '.MAKE' (NetBSD make)
>>> or because their recipes contain the "$(MAKE)" string (GNU and
>>> Solaris make).
>>>
>>> * lib/am/header-vars.am (am__make_dryrun): New variable.
>>> * lib/am/check.am (check-TESTS recheck): Use it, and simplify
>>> recipe accordingly.
>>> * lib/am/distdir.am (distdir): Likewise.
>>> * lib/am/lisp.am ($(am__ELCFILES)): Likewise.
>>> ---
>>> Do you think this patch is good to apply before 1.11.3, or should
>>> we wait after that release?
>>>
>> I've waited after all.  Patch pushed now (to maint).
>>
> And I've pushed the attached follow-up to take more advantage
> of $(am__make_dryrun) in master as well.
> 
Oh dammit, I've attached the wrong patch!  Here is the correct one.

Sorry for the noise,
  Stefano
>From d029740b347df2f4792b56d402e9368e8b741c2a Mon Sep 17 00:00:00 2001
Message-Id: <d029740b347df2f4792b56d402e9368e8b741c2a.1328476250.git.stefano.lattar...@gmail.com>
From: Stefano Lattarini <stefano.lattar...@gmail.com>
Date: Sun, 5 Feb 2012 21:22:01 +0100
Subject: [PATCH] parallel-tests: more uses for '$(am__make_dryrun)'

With this change we refactor some recipes of the parallel-tests
harness to make them use, where appropriate, the new internal
variable '$(am__make_dryrun)' (introduced in the 'maint' branch)
when they need to determine whether make is running in "dry mode",
i.e., with "make -n".  This allows for some simplifications and
for improved uniformity.

* lib/am/check.am (check-TESTS recheck): Use $(am__make_dryrun) and
simplify accordingly.
(am--redo-logs): Delete this internal helper recipe, merged into ...
($(TEST_SUITE_LOG)): ... this, with the help of $(am__make_dryrun).
recipe accordingly.
---
 lib/am/check.am |   90 +++++++++++++++++++++++++++----------------------------
 1 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/lib/am/check.am b/lib/am/check.am
index fb82137..777cb6f 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -129,36 +129,6 @@ am__set_TESTS_bases = \
 	rm -f $< $@
 	$(MAKE) $(AM_MAKEFLAGS) $<
 
-# Helper recipe used by $(TEST_SUITE_LOG) below, to avoid problems with
-# "make -n".  Break this recipe in multiple shell invocations too, to
-# really work as expected with "make -n".
-am--redo-logs:
-	@rm -f $$redo_logs
-	@rm -f $$redo_results
-## The use of the `am__remaking_logs' environment variable below is
-## required to ensure that we don't go into an infinite recursion in
-## case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
-## Yes, this has already happened in practice.  Sigh!
-	@if test -n "$$am__remaking_logs"; then \
-	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
-	       "recursion detected" >&2; \
-	else \
-	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
-	fi;
-## Sanity check: each unreadable or non-existent test result file should
-## has been properly remade at this point, as should the corresponding log
-## file.
-	@st=0;  \
-	errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
-	for i in $$redo_bases; do \
-	  test -f $$i.trs && test -r $$i.trs \
-	    || { echo "$$errmsg $$i.trs"; st=1; }; \
-	  test -f $$i.log && test -r $$i.log \
-	    || { echo "$$errmsg $$i.log"; st=1; }; \
-	done; \
-	test $$st -eq 0
-.PHONY: am--redo-logs
-
 $(TEST_SUITE_LOG): $(TEST_LOGS)
 	@$(am__set_TESTS_bases); \
 ## Helper shell function, tells whether a path refers to an existing,
@@ -178,12 +148,35 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 ## tests in order to re-create them.
 	  redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
 	  redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
-## The exported variables are needed by the helper hook.
-	  redo_bases="$$redo_bases" \
-	  redo_logs="$$redo_logs" \
-	  redo_results="$$redo_results" \
-	    $(MAKE) $(AM_MAKEFLAGS) am--redo-logs || exit 1; \
-	else :; fi;
+	  if $(am__make_dryrun); then :; else \
+## Break "rm -f" into two calls to minimize the possibility of exceeding
+## command line length limits.
+	    rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+	  fi; \
+	fi; \
+## Use a trick to to ensure that we don't go into an infinite recursion
+## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
+## Yes, this has already happened in practice.  Sigh!
+	if test -n "$$am__remaking_logs"; then \
+	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+	       "recursion detected" >&2; \
+	else \
+	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+	fi; \
+	if $(am__make_dryrun); then :; else \
+## Sanity check: each unreadable or non-existent test result file should
+## has been properly remade at this point, as should the corresponding log
+## file.
+	  st=0;  \
+	  errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+	  for i in $$redo_bases; do \
+	    test -f $$i.trs && test -r $$i.trs \
+	      || { echo "$$errmsg $$i.trs"; st=1; }; \
+	    test -f $$i.log && test -r $$i.log \
+	      || { echo "$$errmsg $$i.log"; st=1; }; \
+	  done; \
+	  test $$st -eq 0 || exit 1; \
+	fi
 ## We need a new subshell to work portably with "make -n", since the
 ## previous part of the recipe contained a $(MAKE) invocation.
 	@$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
@@ -335,7 +328,7 @@ check-TESTS recheck:
 ## we rely on .PHONY to work portably.
 	@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
 	@ws='[ 	]'; \
-	list=''; $(am__set_TESTS_bases); \
+	log_list='' trs_list=''; $(am__set_TESTS_bases); \
 	for i in $$bases; do \
 ## If running a "make recheck", we must only consider tests that had an
 ## unexpected outcome (FAIL or XPASS) in the earlier run.  In particular,
@@ -353,21 +346,26 @@ check-TESTS recheck:
 ## 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=$$i.log; else list="$$list $$i.log"; fi; \
+	  if test -z "$$log_list"; then \
+	    log_list="$$i.log"; \
+	  else \
+	    log_list="$$log_list $$i.log"; \
+	  fi; \
+	  if test -z "$$trs_list"; then \
+	    trs_list="$$i.trs"; \
+	  else \
+	    trs_list="$$trs_list $$i.trs"; \
+	  fi; \
 	done; \
 ## 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 && test -n "$$list"; then \
-	  { \
-	   echo 'am--clean: am--clean-log am--clean-trs'; \
-	   echo 'am--clean-log: ; rm -f $$(am__logs)'; \
-	   echo 'am--clean-trs: ; rm -f $$(am__logs:.log=.trs)'; \
-	  } | $(MAKE) $(AM_MAKEFLAGS) -f - am--clean am__logs="$$list" \
-	    || exit 1; \
+	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="$$list"
+	$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
 
 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
 recheck: %CHECK_DEPS%
-- 
1.7.7.3

Reply via email to