automake-ng
[Top][All Lists]
Advanced

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

[Automake-ng] [PATCH 05/10] [ng] parallel-tests: support "TESTS = $(srcd


From: Stefano Lattarini
Subject: [Automake-ng] [PATCH 05/10] [ng] parallel-tests: support "TESTS = $(srcdir)/foo.test"
Date: Mon, 23 Apr 2012 11:57:23 +0200

This change fixes a small but annoying limitation of the parallel
testsuite harness.   Before this change, if $(TESTS) contained a test
case with '$(srcdir)' in its name:

  TESTS = $(srcdir)/foo.test

the parallel testsuite driver would have created the 'foo.log' and
'foo.trs' files in the source directory rather than in the build
directory.  This made it impossible to employ useful constructs of the
following kind:

  TESTS = $(wildcard *.test)

in a VPATH setup.  In fact, the idiom as written above would have missed
any test in the source directory (i.e., any non-generated tests), while
the "corrected" idiom:

  TESTS = $(wildcard $(srcdir)/t[0-9][0-9]*.sh t[0-9][0-9]*.sh)

would have created the '.log' and '.trs' files for any distributed test
in the source directory.

After this change, the "corrected" idiom above is usable, and created
'.log' and '.trs' files in the build directory.

* doc/automake.texi: Don't warn about the old limitation anymore.
* NG-NEWS: Document that that limitation has been lifted.
* lib/am/check.am (am__cooked_tests): New variable, containing all the
entries of $(TESTS) with $(srcdir) prefix (if present) removed.
* am__cooked_tests: Likewise, but for the contents of $(XFAIL_TESTS).
* automake.in (handle_tests): Adjust the definition of $(TEST_LOGS) to
use '$(am__cooked_tests)' instead of raw '$(TESTS)'.
* t/parallel-tests-srcdir-in-test-name.sh: Adjust to test the new
semantics.
* t/list-of-tests.mk (XFAIL_TESTS): Remove the above test, it now
passes.
* t/parallel-tests-dynamic.sh: Enhance a little.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 NG-NEWS                                 |    5 +++
 automake.in                             |    2 +-
 doc/automake.texi                       |    5 ---
 lib/am/check.am                         |   11 ++++++-
 t/list-of-tests.mk                      |    1 -
 t/parallel-tests-dynamic.sh             |    9 +++---
 t/parallel-tests-srcdir-in-test-name.sh |   53 ++++++++++++++++++++++++++++---
 7 files changed, 69 insertions(+), 17 deletions(-)

diff --git a/NG-NEWS b/NG-NEWS
index 95b7262..99cb0bc 100644
--- a/NG-NEWS
+++ b/NG-NEWS
@@ -92,6 +92,11 @@ Parallel testsuite harness
   configure.ac:
     AC_SUBST([LOG_DRIVER], ['unused but required by automake'])
 
+* The parallel testsuite harness realizes whether an entry of $(TESTS)
+  start with $(srcdir) (as in "TESTS = $(srcdir)/foo.test"), and manages
+  to correctly create the corresponding '.log' and '.trs' files in the
+  build directory rather than in the source directory.
+
 * The contents of $(TESTS) are mostly analyzed at make runtime rather
   than at automake runtime, so that it is now possible to use GNU make
   advanced features (like specific builtins or user-defined functions)
diff --git a/automake.in b/automake.in
index 6b9cb94..bb019d4 100644
--- a/automake.in
+++ b/automake.in
@@ -4812,7 +4812,7 @@ sub handle_tests
          push @test_suffixes, '';
 
           define_variable ('am__test_logs1',
-                           '$(patsubst %,%.log,$(strip $(TESTS)))',
+                           '$(patsubst %,%.log,$(strip $(am__cooked_tests)))',
                            INTERNAL);
          my $nhelper = 1;
          foreach my $test_suffix (@test_suffixes)
diff --git a/doc/automake.texi b/doc/automake.texi
index d1e0765..f15c3e5 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -9203,11 +9203,6 @@ the inference rules generated by @command{automake} can 
apply.  For
 literal test names, @command{automake} can generate per-target rules
 to avoid this limitation.
 
address@hidden FIXME: Automake does not warn about these anymore!
-Please note that it is currently not possible to use @code{$(srcdir)/}
-or @code{$(top_srcdir)/} in the @code{TESTS} variable.  This technical
-limitation is necessary to avoid generating test logs in the source tree.
-
 @node Custom Test Drivers
 @section Custom Test Drivers
 
diff --git a/lib/am/check.am b/lib/am/check.am
index 59c5829..546f60c 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -53,6 +53,15 @@ if %?PARALLEL_TESTS%
 ## of more test metadata, and the use of custom test derivers and protocols
 ## (among them, TAP).
 
+# Required to support explicit use of $(srcdir) in TESTS entries.
+# That might actually be very useful in practice, for example in usages
+# like this:
+#   TESTS = $(wildcard $(srcdir)/t[0-9][0-9]*.sh)
+# Removing the '$(srcdir)' in there would cause the idiom to break in
+# VPATH builds.
+am__cooked_tests = $(patsubst $(srcdir)/%,%,$(strip $(TESTS)))
+am__cooked_xfail_tests = $(patsubst $(srcdir)/%,%,$(strip $(XFAIL_TESTS)))
+
 # Restructured Text title and section.
 am__rst_title = { sed 's/.*/   &   /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
 am__rst_section = { sed 'p;s/./=/g;' && echo; }
@@ -92,7 +101,7 @@ if test -n '$(DISABLE_HARD_ERRORS)'; then            \
 else                                                   \
   am__enable_hard_errors=yes;                          \
 fi;                                                    \
-case " $(strip $(XFAIL_TESTS)) " in                    \
+case " $(am__cooked_xfail_tests) " in                  \
   *" $$f "*) am__expect_failure=yes;;                  \
           *) am__expect_failure=no;;                   \
 esac;                                                  \
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index e3febf1..d2b88a3 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -40,7 +40,6 @@ t/instdir-cond2.sh \
 t/interp3.sh \
 t/java-nobase.sh \
 t/objext-pr10128.sh \
-t/parallel-tests-srcdir-in-test-name.sh \
 t/parallel-tests-many.sh \
 t/pr8365-remake-timing.sh \
 t/remake-am-pr10111.sh \
diff --git a/t/parallel-tests-dynamic.sh b/t/parallel-tests-dynamic.sh
index 197046a..3b4fcb9 100755
--- a/t/parallel-tests-dynamic.sh
+++ b/t/parallel-tests-dynamic.sh
@@ -72,9 +72,10 @@ cat > Makefile.am << 'END'
 my_add_dirprefix = $(strip $(1))/$(strip $(2))
 EXTRA_DIST = $(TESTS) get-tests-list
 TEST_EXTENSIONS = .sh
-TESTS = $(wildcard t[0-9][0-9]*.sh) $(shell $(srcdir)/get-tests-list)
+TESTS = $(wildcard $(srcdir)/t[0-9][0-9]*.sh)
+TESTS += $(shell $(srcdir)/get-tests-list)
 TESTS += $(call my_add_dirprefix, t, nosuffix)
-XFAIL_TESTS = $(wildcard t9[0-9]*.sh)
+XFAIL_TESTS = $(wildcard $(srcdir)/t9[0-9]*.sh)
 END
 
 $ACLOCAL
@@ -105,9 +106,7 @@ test "`find . -name *.log`" = ./config.log
 
 $MAKE distcheck > stdout || { cat stdout; Exit 1; }
 cat stdout
-# FIXME: this is currently broken, as the $(wildcard ...) call miss the
-# FIXME: $(srcdir) component ...
-#count_test_results total=11 pass=9 fail=0 xpass=0 xfail=2 skip=0 error=0
+count_test_results total=11 pass=9 fail=0 xpass=0 xfail=2 skip=0 error=0
 
 $MAKE check tests1='$(wildcard t00*.sh t98?.sh)' \
             tests2='$(shell ./get-tests-list | sed 1d)' \
diff --git a/t/parallel-tests-srcdir-in-test-name.sh 
b/t/parallel-tests-srcdir-in-test-name.sh
index 01042a5..4c834d9 100755
--- a/t/parallel-tests-srcdir-in-test-name.sh
+++ b/t/parallel-tests-srcdir-in-test-name.sh
@@ -29,13 +29,58 @@ am_parallel_tests=yes
 echo AC_OUTPUT >> configure.ac
 
 cat > Makefile.am << 'END'
-TESTS = $(srcdir)/bar.test $(top_srcdir)/baz.test
+TESTS = \
+  $(srcdir)/foo \
+  @srcdir@/foo2 \
+  @srcdir@/bar.test \
+  ${srcdir}/sub/baz.test \
+  built.test
+
+XFAIL_TESTS = $(srcdir)/bar.test foo2
+
+built.test:
+       (echo '#!/bin/sh' && echo 'exit 77') >address@hidden
+       chmod a-w,a+x address@hidden && mv -f address@hidden $@
+END
+
+cat > foo <<'END'
+#!/bin/sh
+exit 0
+END
+chmod a+x foo
+
+cat > foo2 <<'END'
+#!/bin/sh
+exit 1
 END
+chmod a+x foo2
+
+cp foo2 bar.test
+
+mkdir sub
+cp foo sub/baz.test
 
 $ACLOCAL
 $AUTOCONF
-AUTOMAKE_fails -a
-grep '$(srcdir).*TESTS.*bar\.test' stderr
-grep '$(top_srcdir).*TESTS.*baz\.test' stderr
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE check
+
+ls -l . .. # For debugging.
+
+test -f built.log
+test -f foo.log
+test -f bar.log
+test -f sub/baz.log
+test -f test-suite.log
+
+test ! -f ../built.log
+test ! -f ../foo.log
+test ! -f ../bar.log
+test ! -f ../sub/baz.log
+test ! -f ../test-suite.log
 
 :
-- 
1.7.9.5




reply via email to

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