This needs some thinking about the naming scheme to use. Here's why: The current Automake default compile naming scheme has the assumption that file extensions have only one default processing output. For example, .c and .cpp become .$(OBJEXT), .y become .c, and so on. Texinfo is an exception, but an ugly one in that it requires an exceptional amount of additional support code inside automake.
Understandably, I would like to keep new namings as much in line with existing ones as possible. However, for test suite drivers, it is entirely reasonable if they provide additional _alternative_ default processing. For example, you could have a driver that processes all your .cxx files and extracts and runs unit test from them. But of course, your .cxx files are also regularly compiled to binary objects, using CXXCOMPILE. Corollary: the test driver may not be called CXXCOMPILE. General: For extension `.ext', we cannot use `EXTCOMPILE' as driver. ext_COMPILE or extCOMPILE seem awkward to me too, as these do not allow for generalization either, and the notational difference would be unintuitive (or even dangerous, think of preprocessed Fortran with .F extension). What else comes to mind? EXTTESTCOMPILE EXT_TESTCOMPILE EXT_TEST_COMPILE EXTLOGCOMPILE EXT_LOGCOMPILE EXT_LOG_COMPILE And then, there is the question: should the *_COMPILE var be something like *_COMPILE = $(TESTS_ENVIRONMENT) $(*C) $(AM_*CFLAGS) $(*CFLAGS) (with '*' suitably replaced as above) and the *C variable take place of the test driver? Thanks, Ralf parallel-tests: per-extension test driver: ext_COMPILE. Turn also the lib/Automake/tests testsuite over to the new test driver. * doc/automake.texi (Tests): Document `ext_COMPILE'. * lib/am/check2.am: Insert `%COMPILE%' right before test. * automake.in (handle_tests): Substitute `COMPILE' for check2, empty for tests without extension, and `$(ext_COMPILE)' for extension `ext'. * configure.ac (AM_INIT_AUTOMAKE): Use `parallel-test' globally. * tests/Makefile.am (AUTOMAKE_OPTIONS): Remove, not needed here any more. * lib/Automake/tests/Makefile.am (TESTS_ENVIRONMENT): Rename to (pl_COMPILE): ... this, as this is a true test driver now. (TESTS_EXTENSIONS): New variable, initialize to `.pl'. * tests/parallel-tests7.test: New test. * tests/Makefile.am: Update. Suggestion by Akim Demaille. diff --git a/automake.in b/automake.in index 2ab266d..12999da 100755 --- a/automake.in +++ b/automake.in @@ -4801,6 +4801,7 @@ sub handle_tests GENERIC => 0, OBJ => $obj, SOURCE => $val, + COMPILE => '', EXT => ''); return $obj; }); @@ -4825,10 +4826,13 @@ sub handle_tests $post = '.log'; $prev = $cur; $nhelper++; + (my $ext = $test_suffix) =~ s/^\.//; + my $compile = '$(' . $ext . '_COMPILE)'; $output_rules .= file_contents ('check2', new Automake::Location, GENERIC => 1, OBJ => '', SOURCE => '$<', + COMPILE => $compile, EXT => $test_suffix) if $test_suffix ne $at_exeext && $test_suffix ne ''; } diff --git a/configure.ac b/configure.ac index 7073d6a..d7bf2fa 100644 --- a/configure.ac +++ b/configure.ac @@ -29,7 +29,7 @@ AC_CANONICAL_BUILD AC_SUBST([am_AUTOCONF], ["${AUTOCONF-autoconf}"]) AC_SUBST([am_AUTOHEADER], ["${AUTOHEADER-autoheader}"]) -AM_INIT_AUTOMAKE([1.10a dist-bzip2 filename-length-max=99 color-tests]) +AM_INIT_AUTOMAKE([1.10a dist-bzip2 filename-length-max=99 color-tests parallel-tests]) # The API version is the base version. We must guarantee # compatibility for all releases with the same API version. diff --git a/doc/automake.texi b/doc/automake.texi index 7a0bfdf..f36e2e7 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -8401,6 +8401,25 @@ extension if any (@pxref{EXEEXT}), as well as any suffix listed in @code{TEST_EXTENSIONS} defaults to @file{.test}. Results are undefined if a test file name ends in several concatenated suffixes. +...@vindex _COMPILE +For tests that match an extension @cod...@var{ext}} listed in +...@code{test_extensions}, you can provide a test driver using the variable +...@code{@var{ext}_COMPILE}. It will cause all tests with this extension +to be called with this driver. For example, + +...@example +TESTS = foo.pl bar.py +TEST_EXTENSIONS = .pl .py +pl_COMPILE = $(PERL) +py_COMPILE = $(PYTHON) +...@end example + +...@noindent +will invoke @samp{$(PERL) foo.pl} and @samp{$(PYTHON) bar.py} to produce +...@file{foo.log} and @file{bar.log}, respectively. The +...@samp{tests_environment} variable is still expanded before the driver, +but should be reserved for the user. + @vindex VERBOSE As with the simple driver above, by default one status line is printed per completed test, and a short summary after the suite has completed. diff --git a/lib/Automake/tests/.gitignore b/lib/Automake/tests/.gitignore new file mode 100644 index 0000000..ffbdfaf --- /dev/null +++ b/lib/Automake/tests/.gitignore @@ -0,0 +1,2 @@ +*.log +*.log-t diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am index acd769f..38ad4f1 100644 --- a/lib/Automake/tests/Makefile.am +++ b/lib/Automake/tests/Makefile.am @@ -15,7 +15,9 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. -TESTS_ENVIRONMENT = $(PERL) -Mstrict -I ../.. -I $(top_srcdir)/lib -w +pl_COMPILE = $(PERL) -Mstrict -I ../.. -I $(top_srcdir)/lib -w +TEST_EXTENSIONS = .pl + TESTS = \ Condition.pl \ Condition-t.pl \ diff --git a/lib/am/check2.am b/lib/am/check2.am index 58ca9e6..237e20a 100644 --- a/lib/am/check2.am +++ b/lib/am/check2.am @@ -17,4 +17,4 @@ ## From a test file to a log file. ?GENERIC?%EXT%.log: ?!GENERIC?%OBJ%: %SOURCE% - @p='%SOURCE%'; $(am__check_pre) "$$tst" $(am__check_post) + @p='%SOURCE%'; $(am__check_pre) %COMPILE% "$$tst" $(am__check_post) diff --git a/tests/Makefile.am b/tests/Makefile.am index e0b7f23..3f31ca9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,4 @@ ## Process this file with automake to create Makefile.in -AUTOMAKE_OPTIONS = parallel-tests XFAIL_TESTS = \ all.test \ @@ -486,6 +485,7 @@ parallel-tests3.test \ parallel-tests4.test \ parallel-tests5.test \ parallel-tests6.test \ +parallel-tests7.test \ parse.test \ percent.test \ percent2.test \ diff --git a/tests/parallel-tests7.test b/tests/parallel-tests7.test new file mode 100755 index 0000000..4a1257d --- /dev/null +++ b/tests/parallel-tests7.test @@ -0,0 +1,84 @@ +#! /bin/sh +# Copyright (C) 2009 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 3, 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 parallel-tests features: +# - per-extension test drivers + +. ./defs-p || Exit 1 +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_OUTPUT +END + +cat > Makefile.am << 'END' +## Note that automake should not match the '/test' part +## of 'sub/test' as '.test' suffix. +TESTS = foo.chk bar.test $(check_PROGRAMS) sub/test +check_PROGRAMS = baz bla.test bli.suff +TEST_EXTENSIONS = .chk .test +chk_COMPILE = ./chk-driver +test_COMPILE = ./test-driver +END + +mkdir sub + +cat >chk-driver <<'END' +#! /bin/sh +echo $0 +exec "$@" +exit 127 +END +chmod a+x chk-driver +cp chk-driver test-driver + +cat >foo.chk << 'END' +#! /bin/sh +exit 0 +END +chmod a+x foo.chk +cp foo.chk bar.test +cp foo.chk sub/test + +cat >baz.c << 'END' +int main (void) +{ + return 0; +} +END +cp baz.c bla.c +cp baz.c bli.c + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +unset TESTS || : + +./configure +$MAKE +$MAKE check +grep chk-driver foo.log +grep test-driver bar.log +test -f baz.log +grep driver baz.log && Exit 1 +grep test-driver bla.log +test -f bli.suff.log +grep driver bli.suff.log && Exit 1 +test -f sub/test.log +grep driver sub/test.log && Exit 1 +: