]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
parallel-tests: don't allow @substitutions@ in TEST_EXTENSIONS
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 6 Oct 2011 19:30:04 +0000 (21:30 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 6 Oct 2011 19:38:38 +0000 (21:38 +0200)
Even after the last commit `v1.11-476-g90bea64', the checks
performed by automake on entries in $(TEST_EXTENSIONS) tried to
allow for @substitited@ stuff.  This however ends up allowing
quite brittle setups, which, most importantly, are of no real
practical usefulness anyway.  So it's better to just disallow
@substitutions@ in TEST_EXTENSIONS altogether, offering a clear
error message, instead of risking weird bugs and unexpected
behaviors in the generated Makefile.in.

* automake.in ($TEST_EXTENSION_PATTERN): Turned from a regular
expression ...
(is_valid_test_extension): ... into this subroutine.  Don't allow
generic @substitutions@ anymore (possibly making an exception for
`@EXEEXT@' under the proper circumstances).
* tests/test-extensions.test: Adjust and extend.

ChangeLog
automake.in
tests/test-extensions.test

index e52a275fadebee929a6e177a1e3f652f905dac80..98771233da776a1eb298b23198ce6e6d81361754 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-10-06  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       parallel-tests: don't allow @substitutions@ in TEST_EXTENSIONS
+       Even after the last commit `v1.11-476-g90bea64', the checks
+       performed by automake on entries in $(TEST_EXTENSIONS) tried to
+       allow for @substitited@ stuff.  This however ends up allowing
+       quite brittle setups, which, most importantly, are of no real
+       practical usefulness anyway.  So it's better to just disallow
+       @substitutions@ in TEST_EXTENSIONS altogether, offering a clear
+       error message, instead of risking weird bugs and unexpected
+       behaviors in the generated Makefile.in.
+       * automake.in ($TEST_EXTENSION_PATTERN): Turned from a regular
+       expression ...
+       (is_valid_test_extension): ... into this subroutine.  Don't allow
+       generic @substitutions@ anymore (possibly making an exception for
+       `@EXEEXT@' under the proper circumstances).
+       * tests/test-extensions.test: Adjust and extend.
+
 2011-10-01  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        parallel-tests: automake error our on invalid TEST_EXTENSIONS
index a60bc9fca067ce31f14d8c0a54f0c13cba35ecfd..0080df8154e3e71dd032bb54926c15353e882f20 100755 (executable)
@@ -213,8 +213,6 @@ my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
 # Directories installed during 'install-exec' phase.
 my $EXEC_DIR_PATTERN =
   '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
-# Suffixes that can appear in TEST_EXTENSIONS (parallel-tests support).
-my $TEST_EXTENSION_PATTERN = '^(\.[a-zA-Z_][a-zA-Z0-9_]*|@[a-zA-Z0-9_]+@)$';
 
 # Values for AC_CANONICAL_*
 use constant AC_CANONICAL_BUILD  => 1;
@@ -4929,6 +4927,19 @@ sub handle_tests_dejagnu
     $output_rules .= file_contents ('dejagnu', new Automake::Location);
 }
 
+# is_valid_test_extension ($EXT)
+# ------------------------------
+# Return true if $EXT can appear in $(TEST_EXTENSIONS), return false
+# otherwise.
+sub is_valid_test_extension ($)
+{
+  my $ext = shift;
+  return 1
+    if ($ext =~ /^\.[a-zA-Z_][a-zA-Z0-9_]*$/);
+  return 1
+    if (exists $configure_vars{'EXEEXT'} && $ext eq subst ('EXEEXT'));
+  return 0;
+}
 
 # Handle TESTS variable and other checks.
 sub handle_tests
@@ -4976,12 +4987,12 @@ sub handle_tests
          my $var = rvar 'TEST_EXTENSIONS';
          my @test_suffixes = $var->value_as_list_recursive;
           if ((my @invalid_test_suffixes =
-                  grep { !/$TEST_EXTENSION_PATTERN/o } @test_suffixes) > 0)
+                  grep { !is_valid_test_extension $_ } @test_suffixes) > 0)
             {
               error $var->rdef (TRUE)->location,
                     "invalid test extensions: @invalid_test_suffixes";
             }
-          @test_suffixes = grep { /$TEST_EXTENSION_PATTERN/o } @test_suffixes;
+          @test_suffixes = grep { is_valid_test_extension $_ } @test_suffixes;
          if ($handle_exeext)
            {
              unshift (@test_suffixes, $at_exeext)
index 1d5872c4e292daf0fb90851647cfff182cd85c94..901d872bc6a62e3b493b286532d2ec133bbdf3dd 100755 (executable)
@@ -24,29 +24,29 @@ parallel_tests=yes
 set -e
 
 cat >> configure.in <<'END'
-AC_SUBST([ext], [".e"])
 AC_OUTPUT
 END
 
 $ACLOCAL
 $AUTOCONF
 
-cat > Makefile.am << 'END'
-TESTS =
-TEST_EXTENSIONS = .sh .T .t1 ._foo .BAR .x_Y_z ._ @ext@
-END
+valid_extensions='sh T t1 _foo BAR x_Y_z _'
+
+echo TESTS = > Makefile.am
+echo " $valid_extensions" \
+  | sed -e 's/ / ./g' -e 's/^/TEST_EXTENSIONS =/' >> Makefile.am
+cat Makefile.am # For debugging.
 
 $AUTOMAKE
 
-$EGREP -i 'log|ext' Makefile.in # For debugging.
+grep -i 'log' Makefile.in # For debugging.
 
-for lc in sh T t1 _foo BAR x_Y_z _; do
+for lc in $valid_extensions; do
   uc=`echo $lc | tr '[a-z]' '[A-Z]'`
   $FGREP "\$(${uc}_LOG_COMPILER)" Makefile.in
   grep "^${uc}_LOG_COMPILE =" Makefile.in
   grep "^\.${lc}\.log:" Makefile.in
 done
-grep "^@ext@\.log:" Makefile.in
 
 # The produced Makefile is not broken.
 ./configure
@@ -54,11 +54,12 @@ $MAKE all check
 
 cat > Makefile.am << 'END'
 TESTS = foo.test bar.sh
-TEST_EXTENSIONS = .test mu .x-y a-b .t.1 .sh .6c .0 .11 .@ .t33 .a=b _&_
+TEST_EXTENSIONS  = .test mu .x-y a-b .t.1 .sh .6c .0 .11 .= @suf@ .@ext@
+TEST_EXTENSIONS += .= .t33 .a@b _&_
 END
 
 AUTOMAKE_fails
-for suf in mu .x-y a-b .t.1 .6c .0 .11 '.@' '.a=b' '_&_'; do
+for suf in mu .x-y a-b .t.1 .6c .0 .11  @suf@ .@ext@ '.=' '_&_'; do
   suf2=`printf '%s\n' "$suf" | sed -e 's/\./\\./'`
   $EGREP "^Makefile\.am:2:.*invalid test extension.* $suf2( |$)" stderr
 done