[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 11/11] [ng] check: per-suffix dependencies for test
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 11/11] [ng] check: per-suffix dependencies for test cases |
Date: |
Wed, 9 May 2012 11:30:16 +0200 |
Akim Demaille asked (in automake bug#11287) for a way to specify extra
dependencies for the test cases, depending on their extension (or lack
thereof). Now that Automake-NG uses pattern rules instead of old-fashion
suffix rules to generate '.log' and '.trs' files from test cases, doing
that is trivial.
* NG-NEWS: Update.
* doc/automake.texi: Document the new feature.
* automake.in (handle_per_suffix_test): Mark the contents of the
'${pfx}LOG_DEPENDENCIES' variable as processed (required to avoid
spurious errors).
* lib/am/check2.am (%.log, %.trs): Depend on '$(%PFX%LOG_DEPENDENCIES)'.
* t/parallel-tests-per-suffix-deps.sh: New test.
* t/parallel-tests-log-compiler-example.sh: Renamed ...
* t/parallel-tests-logvars-example.sh: ... to this, and adjusted to
be more faithful to the updated documentation.
Signed-off-by: Stefano Lattarini <address@hidden>
---
NG-NEWS | 4 +
automake.in | 4 +
doc/automake.texi | 43 ++++--
lib/am/check2.am | 4 +-
...xample.sh => parallel-tests-logvars-example.sh} | 17 +-
t/parallel-tests-per-suffix-deps.sh | 163 ++++++++++++++++++++
6 files changed, 217 insertions(+), 18 deletions(-)
rename t/{parallel-tests-log-compiler-example.sh =>
parallel-tests-logvars-example.sh} (87%)
create mode 100755 t/parallel-tests-per-suffix-deps.sh
diff --git a/NG-NEWS b/NG-NEWS
index 6a66622..08a97d9 100644
--- a/NG-NEWS
+++ b/NG-NEWS
@@ -128,6 +128,10 @@ Parallel testsuite harness
make check RECHECK_LOGS="" # Old API, won't work anymore.
+* Per-suffix dependencies for test cases can be specified through
+ variables "<ext>_LOG_DEPENDENCIES" (this being simply "LOG_DEPENDENCIES"
+ for suffix-less tests).
+
Miscellaneous
=============
diff --git a/automake.in b/automake.in
index c553e4e..c5ebdc6 100644
--- a/automake.in
+++ b/automake.in
@@ -4716,6 +4716,10 @@ sub handle_per_suffix_test($)
"\$(SHELL) $am_config_aux_dir/test-driver",
INTERNAL);
}
+ # Required to avoid spurious errors like:
+ # ``variable 'LOG_DEPENDENCIES' is defined but no program or
+ # library has 'LOG' as canonical name (possible typo)''
+ set_seen ("${pfx}LOG_DEPENDENCIES");
$output_rules .= file_contents ('check2', new Automake::Location,
PFX => $pfx,
EXT => $test_suffix);
diff --git a/doc/automake.texi b/doc/automake.texi
index eb17778..4ff438b 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -9018,33 +9018,52 @@ while @samp{.x-y}, @samp{.6c} and @samp{.t.1} are not.
@vindex @var{ext}_LOG_FLAGS
@vindex address@hidden
@vindex AM_LOG_FLAGS
address@hidden
For tests that match an extension @address@hidden listed in
address@hidden, you can provide a custom ``test runner'' using
-the variable @address@hidden (note the upper-case
-extension) and pass options in @address@hidden and allow
-the user to pass options in @address@hidden It will cause
-all tests with this extension to be called with this runner. For all
-tests without a registered extension, the variables @code{LOG_COMPILER},
address@hidden, and @code{LOG_FLAGS} may be used. For example,
address@hidden, you can:
+
address@hidden
address@hidden
+declare extra dependencies through @address@hidden;
address@hidden
+provide a custom ``test runner'' using @address@hidden,
+(it will be used to run all the tests with this extension);
address@hidden
+pass options to that runner through @address@hidden;
address@hidden
+allow the user to pass further options through @address@hidden
address@hidden itemize
address@hidden Keep in sync with parallel-tests-log-compiler-example.sh
address@hidden
+Similarly, for tests without a registered extension, the variables
address@hidden, @code{LOG_COMPILER}, @code{AM_LOG_FLAGS} and
address@hidden may be used for those same purposes.
+
+Let's see an example.
+
address@hidden Keep in sync with parallel-tests-logvars-example.sh
@example
TESTS = foo.pl bar.py baz
TEST_EXTENSIONS = .pl .py
+
PL_LOG_COMPILER = $(PERL)
AM_PL_LOG_FLAGS = -w
+
PY_LOG_COMPILER = $(PYTHON)
AM_PY_LOG_FLAGS = -v
+PY_LOG_DEPENDENCIES = mymod.py
+
LOG_COMPILER = ./wrapper-script
AM_LOG_FLAGS = -d
@end example
@noindent
-will invoke @samp{$(PERL) -w foo.pl}, @samp{$(PYTHON) -v bar.py},
+The above will invoke @samp{$(PERL) -w foo.pl}, @samp{$(PYTHON) -v bar.py},
and @samp{./wrapper-script -d baz} to produce @file{foo.log},
address@hidden, and @file{baz.log}, respectively. The @file{foo.trs},
address@hidden and @file{baz.trs} files will be automatically produced
-as a side-effect.
address@hidden, and @file{baz.log}, respectively, and will ensure
+the python module @file{mymod.py} is built before the @file{bar.py}
+test is run. The @file{foo.trs}, @file{bar.trs} and @file{baz.trs}
+files will be automatically produced as a side-effect.
It's important to note that, differently from what we've seen for the
serial test harness (@pxref{Parallel Test Harness}), the
diff --git a/lib/am/check2.am b/lib/am/check2.am
index 34fdd58..486944c 100644
--- a/lib/am/check2.am
+++ b/lib/am/check2.am
@@ -53,7 +53,7 @@ am__runtest = \
endif %?FIRST%
## From a test file to a .log and .trs file.
-%.log %.trs: %%EXT%
+%.log %.trs: %%EXT% $(%PFX%LOG_DEPENDENCIES)
@$(call am__runtest,%PFX%)
## If no programs are built in this package, then this rule is removed
@@ -62,7 +62,7 @@ if %HANDLE-EXEEXT%
## FIXME: spurious indentnation to avoid Automake thinking this is an
## automake conditional.
ifdef EXEEXT
-%.log %.trs: %%EXT%$(EXEEXT)
+%.log %.trs: %%EXT%$(EXEEXT) $(%PFX%LOG_DEPENDENCIES)
@$(call am__runtest,%PFX%)
endif
endif %HANDLE-EXEEXT%
diff --git a/t/parallel-tests-log-compiler-example.sh
b/t/parallel-tests-logvars-example.sh
similarity index 87%
rename from t/parallel-tests-log-compiler-example.sh
rename to t/parallel-tests-logvars-example.sh
index 8b45758..fc922a5 100755
--- a/t/parallel-tests-log-compiler-example.sh
+++ b/t/parallel-tests-logvars-example.sh
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test the example of usage of generic and extension-specific
-# LOG_COMPILER and LOG_FLAGS given in the manual.
+# LOG_COMPILER, LOG_FLAGS and LOG_DEPENDNECIES given in the manual.
am_parallel_tests=yes
required=python
@@ -30,16 +30,22 @@ END
cat > Makefile.am << 'END'
TESTS = foo.pl bar.py baz
TEST_EXTENSIONS = .pl .py
+
PL_LOG_COMPILER = $(PERL)
AM_PL_LOG_FLAGS = -w
-PY_LOG_COMPILER = $(PYTHON)
-AM_PY_LOG_FLAGS = -v
+
LOG_COMPILER = ./wrapper-script
AM_LOG_FLAGS = -d
+
+PY_LOG_COMPILER = $(PYTHON)
+AM_PY_LOG_FLAGS = -v
+PY_LOG_DEPENDENCIES = mymod.py
+mymod.py:
+ echo "import sys" >$@
END
echo 'my $a =+ 2; exit (0);' > foo.pl
-echo 'import sys; sys.exit(0);' > bar.py
+echo 'import mymod; mymod.sys.exit(0);' > bar.py
: > baz
cat > wrapper-script <<'END'
@@ -59,6 +65,9 @@ $MAKE check || st=$?
cat foo.log
cat bar.log
cat baz.log
+cat foo.trs
+cat bar.trs
+cat baz.trs
test $st -eq 0 || Exit $st
# Check that the wrappers have been run with the expected flags.
diff --git a/t/parallel-tests-per-suffix-deps.sh
b/t/parallel-tests-per-suffix-deps.sh
new file mode 100755
index 0000000..496c9f6
--- /dev/null
+++ b/t/parallel-tests-per-suffix-deps.sh
@@ -0,0 +1,163 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# The user should be able to easily specify extra dependencies for
+# the test cases, depending on their extension (or lack thereof).
+# We do so with the help of "${prefix}LOG_DEPENDENCIES" variables.
+# See the last wishlist in automake bug#11287.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_SUBST([EXEEXT], [.bin])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .test .sh
+TESTS = foo.test foo2.test bar.sh baz zard.oz quux.bin mu.test.bin
+
+TEST_LOG_DEPENDENCIES = test-dep
+SH_LOG_DEPENDENCIES = sh-dep1 sh-dep2
+LOG_DEPENDENCIES = dep
+
+DEPS = test-dep sh-dep1 sh-dep2 dep new-test-dep
+$(DEPS):
+ echo dummy > $@
+CLEANFILES = $(DEPS)
+
+.PHONY: setup
+setup:
+ chmod a+x $(TESTS)
+EXTRA_DIST = $(TESTS)
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+test -f test-dep || test -f new-test-dep
+END
+
+cat > foo2.test <<'END'
+#! /bin/sh
+test -f test-dep
+END
+
+cp foo2.test mu.test.bin
+
+cat > bar.sh <<'END'
+#! /bin/sh
+test -f sh-dep1 && test -f sh-dep2
+END
+
+cat > baz <<'END'
+#! /bin/sh
+test -f dep
+END
+
+cp baz quux.bin
+
+cat > zard.oz <<'END'
+#! /bin/sh
+test -f dep
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE setup
+
+cleanup () { rm -f test-dep sh-dep1 sh-dep2 dep; }
+
+$MAKE check -j4
+test ! -f new-test-dep
+test -f test-dep
+test -f sh-dep1
+test -f sh-dep2
+test -f dep
+test -f quux.log # Sanity check.
+test -f mu.log # Likewise.
+
+cleanup
+
+$MAKE check TESTS=foo.test
+test -f test-dep
+test ! -f sh-dep1
+test ! -f sh-dep2
+test ! -f dep
+
+cleanup
+rm -f bar.log
+$MAKE check TESTS=bar.sh AM_LAZY_CHECK=yes
+test ! -f test-dep
+test -f sh-dep1
+test -f sh-dep2
+test ! -f dep
+
+cleanup
+$MAKE check TESTS=baz
+test ! -f test-dep
+test ! -f sh-dep1
+test ! -f sh-dep2
+test -f dep
+
+cleanup
+$MAKE check TESTS='foo bar'
+test -f test-dep
+test -f sh-dep1
+test -f sh-dep2
+test ! -f dep
+
+cleanup
+$MAKE check TESTS=zard.oz
+test ! -f test-dep
+test ! -f sh-dep1
+test ! -f sh-dep2
+test -f dep
+
+cleanup
+$MAKE check TESTS=mu.test.bin
+test -f test-dep
+test ! -f sh-dep1
+test ! -f sh-dep2
+test ! -f dep
+
+cleanup
+$MAKE check TESTS='quux.bin bar.sh'
+test ! -f test-dep
+test -f sh-dep1
+test -f sh-dep2
+test -f dep
+
+cleanup
+$MAKE check TESTS=foo TEST_LOG_DEPENDENCIES=new-test-dep
+test -f new-test-dep
+test ! -f test-dep
+test ! -f sh-dep1
+test ! -f sh-dep2
+test ! -f dep
+
+cleanup
+$MAKE check TESTS=baz XFAIL_TESTS=baz LOG_DEPENDENCIES=
+test ! -f dep
+grep ':test-result: XFAIL' baz.trs
+
+$MAKE distcheck
+
+:
--
1.7.9.5
- [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 03/11] [ng] check: refactoring to reduce code duplication, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 04/11] [ng] check: refactor (better names for internal vars), Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 05/11] [ng] check: minor refactoring (reorder code), Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 02/11] [ng] refactor: get rid of am__EXEEXT (automake conditional and %transform), Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 01/11] [ng] check: big refactoring with semantic changes in parallel-tests support, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 08/11] [ng] check: AM_LAZY_CHECK="yes", not RECHECK_TESTS="", for lazy re-runs, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 07/11] [ng] check: refactor: split recipes for check-TESTS and recheck, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 06/11] [ng] check: minor refactoring (prefer make time over recipe time), Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 11/11] [ng] check: per-suffix dependencies for test cases,
Stefano Lattarini <=
- [Automake-NG] [PATCH 10/11] [ng] check: few minor simplifications, Stefano Lattarini, 2012/05/09
- [Automake-NG] [PATCH 09/11] [ng] tests: remove overly picky test cases (and fix few typos), Stefano Lattarini, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Akim Demaille, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Stefano Lattarini, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Akim Demaille, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Stefano Lattarini, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Bob Friesenhahn, 2012/05/09
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Stefano Lattarini, 2012/05/10
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Bob Friesenhahn, 2012/05/10
- Re: [Automake-NG] [PATCH 00/11] Several changes to parallel-tests support, Stefano Lattarini, 2012/05/10