* lib/am/check.am (am__TEST_BASES): Removed, it's role taken over by ... (am__set_TESTS_bases): ... these new variable. ($(TEST_SUITE_LOG): Use it, to avoid VPATH rewrite issues. * automake.in (handle_tests): Update the code for the cleanup of the `.trs' file to use `$(TEST_LOGS)' instead of `$(am__TEST_BASES)'. * tests/test-harness-vpath-rewrite.test: New test, better exposing the problem fixed by this change * tests/Makefile.am (TESTS): Add it. * tests/test-trs-basic.test: Update and extend. --- ChangeLog | 15 ++++++++ automake.in | 2 +- lib/am/check.am | 21 ++++++++--- tests/Makefile.am | 1 + tests/Makefile.in | 20 ++++++++--- tests/test-harness-vpath-rewrite.test | 59 +++++++++++++++++++++++++++++++++ tests/test-trs-basic.test | 35 ++++++++++++++----- 7 files changed, 131 insertions(+), 22 deletions(-) create mode 100755 tests/test-harness-vpath-rewrite.test
diff --git a/ChangeLog b/ChangeLog index e715e89..5330296 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-08-08 Stefano Lattarini <stefano.lattar...@gmail.com> + + test harness: work around a VPATH rewrite issue + * lib/am/check.am (am__TEST_BASES): Removed, it's role taken + over by ... + (am__set_TESTS_bases): ... these new variable. + ($(TEST_SUITE_LOG): Use it, to avoid VPATH rewrite issues. + * automake.in (handle_tests): Update the code for the cleanup + of the `.trs' file to use `$(TEST_LOGS)' instead of + `$(am__TEST_BASES)'. + * tests/test-harness-vpath-rewrite.test: New test, better + exposing the problem fixed by this change + * tests/Makefile.am (TESTS): Add it. + * tests/test-trs-basic.test: Update and extend. + 2011-08-07 Stefano Lattarini <stefano.lattar...@gmail.com> parallel-tests: work around Solaris XPG4 make segfault diff --git a/automake.in b/automake.in index bccacf1..b8fdde3 100644 --- a/automake.in +++ b/automake.in @@ -5119,7 +5119,7 @@ sub handle_tests } } $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN; - $clean_files{'$(am__TEST_BASES:=.trs)'} = MOSTLY_CLEAN; + $clean_files{'$(TEST_LOGS:.log=.trs)'} = MOSTLY_CLEAN; $clean_files{'$(TEST_SUITE_LOG)'} = MOSTLY_CLEAN; $clean_files{'$(TEST_SUITE_HTML)'} = MOSTLY_CLEAN; } diff --git a/lib/am/check.am b/lib/am/check.am index 840914a..035b4c1 100644 --- a/lib/am/check.am +++ b/lib/am/check.am @@ -104,10 +104,19 @@ case " $(XFAIL_TESTS) " in \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# The names of the tests, with any registered extension removed. Or -# equivalently, the names of the test logs, with the `.log' extension -# renoved. This honours runtime overriding of TESTS and TEST_LOGS. -am__TEST_BASES = $(TEST_LOGS:.log=) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the `.log' extension removed). The result is saved in the shell variable +# `$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.test'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for f in $$bases; do echo $$f; done | sed 's/\.log//'`; \ +## Trim away any extra whitespace. This has already proved useful in +## avoiding weird bug on lesser make implementations. + bases=`echo $$bases` # This can be used instead of $(MAKE) in recipes requiring a recursive call # to make, but which are not intended to be executed by "make -n". See the @@ -125,7 +134,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) ## Helper shell function, tells whether a path refers to an existing, ## regular, readable file. f_ok () { test -f "$$1" && test -r "$$1"; }; \ - bases='$(am__TEST_BASES)'; \ + $(am__set_TESTS_bases); \ ws='[ ]'; \ ## We need to ensures that all the required `.trs' and `.log' files will ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG) @@ -343,7 +352,7 @@ AM_RECURSIVE_TARGETS += check-html recheck recheck-html: @ws='[ ]'; \ target=`echo $@ | sed 's,^re,,'`; \ - bases='$(am__TEST_BASES)'; \ + $(am__set_TESTS_bases); \ list=`for b in $$bases; do \ ## Skip tests that haven't been run, but recover gracefully from deleted ## `.trs' files. diff --git a/tests/Makefile.am b/tests/Makefile.am index 43c11d1..57d46f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -762,6 +762,7 @@ test-driver-create-log-dir.test \ test-driver-strip-vpath.test \ test-driver-trs-suffix-registered.test \ test-driver-fail.test \ +test-harness-vpath-rewrite.test \ test-log.test \ test-metadata-global-log.test \ test-metadata-global-result.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 3da9cab..fccee03 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -160,10 +160,17 @@ case " $(XFAIL_TESTS) " in \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# The names of the tests, with any registered extension removed. Or -# equivalently, the names of the test logs, with the `.log' extension -# renoved. This honours runtime overriding of TESTS and TEST_LOGS. -am__TEST_BASES = $(TEST_LOGS:.log=) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the `.log' extension removed). The result is saved in the shell variable +# `$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.test'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for f in $$bases; do echo $$f; done | sed 's/\.log//'`; \ + bases=`echo $$bases` # This can be used instead of $(MAKE) in recipes requiring a recursive call # to make, but which are not intended to be executed by "make -n". See the # GNU make manual for more details. @@ -1017,6 +1024,7 @@ test-driver-create-log-dir.test \ test-driver-strip-vpath.test \ test-driver-trs-suffix-registered.test \ test-driver-fail.test \ +test-harness-vpath-rewrite.test \ test-log.test \ test-metadata-global-log.test \ test-metadata-global-result.test \ @@ -1497,7 +1505,7 @@ cscope cscopelist: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__sh_e_setup); $(am__tty_colors); \ f_ok () { test -f "$$1" && test -r "$$1"; }; \ - bases='$(am__TEST_BASES)'; \ + $(am__set_TESTS_bases); \ ws='[ ]'; \ redo_bases=`for b in $$bases; do \ f_ok $$b.trs && f_ok $$b.log || echo $$b; \ @@ -1644,7 +1652,7 @@ check-html: recheck recheck-html: @ws='[ ]'; \ target=`echo $@ | sed 's,^re,,'`; \ - bases='$(am__TEST_BASES)'; \ + $(am__set_TESTS_bases); \ list=`for b in $$bases; do \ test -f $$b.trs || test -f $$b.log || continue; \ grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$b.trs \ diff --git a/tests/test-harness-vpath-rewrite.test b/tests/test-harness-vpath-rewrite.test new file mode 100755 index 0000000..57ff909 --- /dev/null +++ b/tests/test-harness-vpath-rewrite.test @@ -0,0 +1,59 @@ +#! /bin/sh +# Copyright (C) 2010, 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that our concurrent test harness is not subject to spurious VPATH +# rewrites. + +parallel_tests=yes +. ./defs || Exit 1 + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +LOG_COMPILER = true +empty = +TESTS = x0 foo bar baz x1 +EXTRA_DIST = $(TESTS) +END + +: > x0 +: > foo +: > bar +: > baz +: > x1 + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +mkdir build +cd build +../configure +$MAKE check +test -f test-suite.log +test -f foo.log +test -f foo.trs +test -f bar.log +test -f bar.trs +test -f baz.log +test -f baz.trs +# We don't want VPATH rewrites, really. +$MAKE check -n | $EGREP '\.\./(foo|bar|baz)( |$)' && Exit 1 +$MAKE distcheck + +: diff --git a/tests/test-trs-basic.test b/tests/test-trs-basic.test index 88f1276..a9c34a5 100755 --- a/tests/test-trs-basic.test +++ b/tests/test-trs-basic.test @@ -31,9 +31,10 @@ TESTS = foo.test bar.sh sub/zardoz.test TEST_LOG_COMPILER = $(SHELL) SH_LOG_COMPILER = $(SHELL) -## Used to check some internal details. +## Used to check some internal details. And yes, the quotes around +## `$bases' are deliberate: they check for whitespace normalization. tb: - echo $(am__TEST_BASES) > $@ + $(am__set_TESTS_bases); echo "$$bases" > $@ END cat > foo.test << 'END' @@ -50,18 +51,34 @@ $ACLOCAL $AUTOCONF $AUTOMAKE -a -./configure # # Check some internal details first. # -$MAKE tb -test x"`cat tb`" = x"foo bar sub/zardoz" -rm -f tb -TESTS='foo.test foo2.sh foo3.exe foo4' $MAKE -e tb -test x"`cat tb`" = x"foo foo2 foo3.exe foo4" -rm -f tb +for vpath in : false; do + + if $vpath; then + srcdir=.. + mkdir build + cd build + else + srcdir=. + fi + + $srcdir/configure + + $MAKE tb + test x"`cat tb`" = x"foo bar sub/zardoz" + rm -f tb + # Please don't change the order of the stuff in TESTS, below. + TESTS='a foo.test foo2.sh foo3 foo.log foo-log foolog b.exe' $MAKE -e tb + test x"`cat tb`" = x"a foo foo2 foo3 foo.log foo-log foolog b.exe" + rm -f tb + + cd $srcdir + +done # # The `test-suite.stamp' file and the `.trs' files get created by -- 1.7.2.3