]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] parallel-tests: support "TESTS = $(srcdir)/foo.test"
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 22 Apr 2012 14:37:11 +0000 (16:37 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 23 Apr 2012 08:01:06 +0000 (10:01 +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 <stefano.lattarini@gmail.com>
NG-NEWS
automake.in
doc/automake.texi
lib/am/check.am
t/list-of-tests.mk
t/parallel-tests-dynamic.sh
t/parallel-tests-srcdir-in-test-name.sh

diff --git a/NG-NEWS b/NG-NEWS
index 95b72622316c5fb3b096cab1334c9a8996efd54c..99cb0bc1d414281fa1454e35963294b738eef930 100644 (file)
--- 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)
index 6b9cb9454e0f1874c98cab2e74d7ca3883480d4a..bb019d4f386ad84afe60146a06f8d5881f5f1514 100644 (file)
@@ -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)
index d1e076547de00fb7c8907ffbd3c8469b8a23481b..f15c3e57026ce0009f7f9b544877994d20c05f81 100644 (file)
@@ -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.
 
-@c 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
 
index 59c582986ae0299718f2e267968467f64b7eb905..546f60c70bac7f821b77b7117c7008446bc3f752 100644 (file)
@@ -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;                                                  \
index e3febf191f01d598bde94be0c21814a678f6f65b..d2b88a3c81428b70bdc5efa491c05493e32a5660 100644 (file)
@@ -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 \
index 197046af2d64f0b1157dddd7382c50bb69732e0e..3b4fcb9836148c17c17fa899e5c091bdd470e569 100755 (executable)
@@ -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)' \
index 01042a535fb8bb949f0fb594e0927c01d19f8200..4c834d900e582658b81a2934a2d5bb32de07e7e7 100755 (executable)
@@ -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') >$@-t
+       chmod a-w,a+x $@-t && mv -f $@-t $@
+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
 
 :