automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed patch: parallel-tests: per-extension test driver: ext_COMPI


From: Ralf Wildenhues
Subject: Re: proposed patch: parallel-tests: per-extension test driver: ext_COMPILE.
Date: Tue, 24 Mar 2009 22:57:16 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Akim,

* Akim Demaille wrote on Sat, Mar 14, 2009 at 01:52:33PM CET:
> Le 14 mars 09 à 12:08, Ralf Wildenhues a écrit :
>
>> 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
>
> I vote for the last one.  Maybe COMPILER instead of COMPILE, and have  
> the COMPILER + FLAGS go into COMPILE.
>
> Maybe we should depart from COMPILE/COMPILER bw.  I like it, but it  
> might be misleading.  Maybe CONVERT/TRANSLATE or something more general 
> that COMPILE?  Or FROM_EXT_TO_LOG.  Not so nice :(

How about this?  I really appreciate a look over this.

Note that for extension .foo, the variable names will be FOO_LOG_*,
i.e., remove the dot, then uppercase the rest.

I chose to go all the way and add AM_*FLAGS too.

One could, as a generalization, even add, for the non-extension rules,
add
  LOG_COMPILER = $(LOG_COMPILE) $(AM_LOG_FLAGS) $(LOG_FLAGS)

but I haven't done that yet.  WDYT?

Thanks,
Ralf

    parallel-tests: per-extension test driver: <EXT>_LOG_COMPILER.
    
    For test files with extension <ext>, introduce the internal
    variable <EXT>_LOG_COMPILE, which expands to
    $(<EXT>_LOG_COMPILER) $(AM_<EXT>_LOG_FLAGS) $(<EXT>_LOG_FLAGS).
    Turn also the lib/Automake/tests testsuite over to the new
    test driver.
    * doc/automake.texi (Tests): Document `EXT_LOG_COMPILER' and
    `EXT_LOG_FLAGS'.
    * lib/am/check2.am: Insert `%COMPILE%' right before test.
    * automake.in (handle_tests): Substitute `COMPILE' for check2,
    empty for tests without extension, and `$(ext_LOG_COMPILE)' for
    extension `ext'.  In the latter case, define it from the public
    components.
    * 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): Split ...
    (PL_LOG_COMPILER, PL_LOG_FLAGS): ... into these new variables.
    (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..433f88e 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,12 +4826,21 @@ sub handle_tests
              $post = '.log';
              $prev = $cur;
              $nhelper++;
-             $output_rules .= file_contents ('check2', new Automake::Location,
-                                             GENERIC => 1,
-                                             OBJ => '',
-                                             SOURCE => '$<',
-                                             EXT => $test_suffix)
-               if $test_suffix ne $at_exeext && $test_suffix ne '';
+             if ($test_suffix ne $at_exeext && $test_suffix ne '')
+               {
+                 (my $ext = $test_suffix) =~ s/^\.//;
+                 $ext = uc $ext;
+                 my $compile = $ext . '_LOG_COMPILE';
+                 define_variable ($compile,
+                                  '$(' . $ext . '_LOG_COMPILER) $(AM_' .  $ext 
. '_LOG_FLAGS)'
+                                  . ' $(' . $ext . '_LOG_FLAGS)', INTERNAL);
+                 $output_rules .= file_contents ('check2', new 
Automake::Location,
+                                                 GENERIC => 1,
+                                                 OBJ => '',
+                                                 SOURCE => '$<',
+                                                 COMPILE => '$(' . $compile . 
')' ,
+                                                 EXT => $test_suffix);
+               }
            }
 
          define_variable ('TEST_LOGS_TMP', '$(TEST_LOGS:.log=.log-t)', 
INTERNAL);
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..d3b72a5 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -8401,6 +8401,34 @@ 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.
 
address@hidden _LOG_COMPILER
address@hidden _LOG_FLAGS
address@hidden @var{EXT}_LOG_COMPILE
address@hidden @var{EXT}_LOG_COMPILER
address@hidden @var{EXT}_LOG_FLAGS
address@hidden address@hidden
+For tests that match an extension @address@hidden listed in
address@hidden, you can provide a test driver using the variable
address@hidden@var{ext}_LOG_COMPILER} (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 driver.  For example,
+
address@hidden
+TESTS = foo.pl bar.py
+TEST_EXTENSIONS = .pl .py
+PL_LOG_COMPILER = $(PERL)
+PL_LOG_FLAGS = -w
+PY_LOG_COMPILER = $(PYTHON)
+PY_LOG_FLAGS = -v
address@hidden example
+
address@hidden
+will invoke @samp{$(PERL) -w foo.pl} and @samp{$(PYTHON) -v bar.py} to
+produce @file{foo.log} and @file{bar.log}, respectively.  The
address@hidden 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..ad5d45e 100644
--- a/lib/Automake/tests/Makefile.am
+++ b/lib/Automake/tests/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 
-## Copyright (C) 2002, 2003, 2008  Free Software Foundation, Inc.
+## Copyright (C) 2002, 2003, 2008, 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
@@ -15,7 +15,10 @@
 ## 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_LOG_COMPILER = $(PERL)
+PL_LOG_FLAGS = -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..6bdaaff
--- /dev/null
+++ b/tests/parallel-tests7.test
@@ -0,0 +1,90 @@
+#! /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_LOG_COMPILER = ./chk-driver
+TEST_LOG_COMPILER = ./test-driver
+AM_CHK_LOG_FLAGS = 1
+CHK_LOG_FLAGS = 2
+AM_TEST_LOG_FLAGS = 3
+TEST_LOG_FLAGS = 4
+END
+
+mkdir sub
+
+cat >chk-driver <<'END'
+#! /bin/sh
+echo $0 "$@"
+shift
+shift
+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  *1  *2' foo.log
+grep 'test-driver  *3  *4' bar.log
+test -f baz.log
+grep driver baz.log && Exit 1
+grep 'test-driver  *3  *4' 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
+:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]