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).
+
Pattern rules and suffix rules
==============================
"\$(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);
@vindex @var{ext}_LOG_FLAGS
@vindex AM_@var{ext}_LOG_FLAGS
@vindex AM_LOG_FLAGS
+@noindent
For tests that match an extension @code{.@var{ext}} listed in
-@code{TEST_EXTENSIONS}, you can provide a custom ``test runner'' using
-the variable @code{@var{ext}_LOG_COMPILER} (note the upper-case
-extension) and pass options in @code{AM_@var{ext}_LOG_FLAGS} and allow
-the user to pass options in @code{@var{ext}_LOG_FLAGS}. 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},
-@code{AM_LOG_FLAGS}, and @code{LOG_FLAGS} may be used. For example,
+@code{TEST_EXTENSIONS}, you can:
+
+@itemize
+@item
+declare extra dependencies through @code{@var{ext}_LOG_DEPENDENCIES};
+@item
+provide a custom ``test runner'' using @code{@var{ext}_LOG_COMPILER},
+(it will be used to run all the tests with this extension);
+@item
+pass options to that runner through @code{AM_@var{ext}_LOG_FLAGS};
+@item
+allow the user to pass further options through @code{@var{ext}_LOG_FLAGS}.
+@end itemize
+
+@noindent
+Similarly, for tests without a registered extension, the variables
+@code{LOG_DEPENDENCIES}, @code{LOG_COMPILER}, @code{AM_LOG_FLAGS} and
+@code{LOG_FLAGS} may be used for those same purposes.
+
+Let's see an example.
-@c Keep in sync with parallel-tests-log-compiler-example.sh
+@c 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},
-@file{bar.log}, and @file{baz.log}, respectively. The @file{foo.trs},
-@file{bar.trs} and @file{baz.trs} files will be automatically produced
-as a side-effect.
+@file{bar.log}, 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
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
## 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%
# 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
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'
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.
--- /dev/null
+#! /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
+
+: