automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [PATCH 16/17] [ng] check: support conditional $(TEST_EXTEN


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 16/17] [ng] check: support conditional $(TEST_EXTENSIONS)
Date: Tue, 22 May 2012 22:50:57 +0200

That is pretty easy to do with the current code base; just ...

* automake.in (handle_tests): ... stop erroring on conditional contents
of TEST_EXTENSIONS, and move the definitions of a default TEST_EXTENSIONS
variable ...
* lib/am/parallel-tests.am: ... in here.
* t/test-extensions-cond.sh: Rewritten to adapt to the new semantic.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 automake.in               |   11 -----
 lib/am/parallel-tests.am  |    3 ++
 t/test-extensions-cond.sh |  107 +++++++++++++++++++++++++++++++--------------
 3 files changed, 77 insertions(+), 44 deletions(-)

diff --git a/automake.in b/automake.in
index 8f59332..ce99d93 100644
--- a/automake.in
+++ b/automake.in
@@ -4581,18 +4581,7 @@ sub handle_tests
       else
         {
          define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL);
-         my $suff = '.test';
-         define_variable ('TEST_EXTENSIONS', '.test', INTERNAL)
-            if (! var 'TEST_EXTENSIONS');
           require_conf_file ("parallel-tests", FOREIGN, 'test-driver');
-          my $var = var 'TEST_EXTENSIONS';
-          # Currently, we are not able to deal with conditional contents
-          # in TEST_EXTENSIONS.
-          if ($var->has_conditional_contents)
-           {
-            msg_var 'unsupported', $var,
-                     "'TEST_EXTENSIONS' cannot have conditional contents";
-           }
           $output_rules .=
             file_contents ('parallel-tests', new Automake::Location,
                            COLOR => !! option 'color-tests',
diff --git a/lib/am/parallel-tests.am b/lib/am/parallel-tests.am
index 4d3aec0..1d08687 100644
--- a/lib/am/parallel-tests.am
+++ b/lib/am/parallel-tests.am
@@ -74,6 +74,9 @@ am__tpfx = $(if $(strip $1),$(call am__toupper,$(strip 
$(1))_))
 !endif # am__handle_exeext = yes
 !endef
 !
+## FIXME: this will pick up the default from the environment; are we sure
+## FIXME: we want that?
+!TEST_EXTENSIONS ?= .test
 ## FIXME: it would be nice to break these on multiple lines.  Unfortnately,
 ## FIXME: our '!' is not yet smart enough to handle that :-(
 !$(foreach am__e,$(am__dotless_test_extensions),$(eval $(call 
am__handle_per_suffix_test,$(am__e))))
diff --git a/t/test-extensions-cond.sh b/t/test-extensions-cond.sh
index e081d79..d7f78db 100755
--- a/t/test-extensions-cond.sh
+++ b/t/test-extensions-cond.sh
@@ -14,56 +14,97 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Expose bug in conditional definition of TEST_EXTENSIONS.
+# Conditional definition of TEST_EXTENSIONS is supported.
 
 . ./defs || Exit 1
 
 cat >> configure.ac << 'END'
-AM_CONDITIONAL([COND], [:])
-AM_CONDITIONAL([COND2], [:])
+AC_CONFIG_FILES([sub/Makefile])
+AM_CONDITIONAL([COND1], [test x"$cond1" = x"yes"])
+AM_CONDITIONAL([COND2], [test x"$cond2" = x"yes"])
+AC_OUTPUT
 END
 
-$ACLOCAL
+mkdir sub
 
-cat > 1.am << 'END'
-TESTS =
-if COND
-## lineno 4
-TEST_EXTENSIONS = .foo
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+TESTS = foo.sh bar.test
+if COND1
+TEST_EXTENSIONS = .sh
 endif
 END
 
-cat > 2.am << 'END'
-TESTS =
-## lineno 3
-TEST_EXTENSIONS = .foo
-if COND
-# Do nothing.
+cat > sub/Makefile.am << 'END'
+TESTS = 1.sh 2.bar 3.x
+TEST_EXTENSIONS = .sh
+if COND1
+if !COND2
+TEST_EXTENSIONS += .x
+endif
 else
 TEST_EXTENSIONS += .bar
 endif
 END
 
-cat > 3.am << 'END'
-TESTS =
-if COND
-if !COND2
-TESTS = x
-else
-## lineno 7
-TEST_EXTENSIONS = .foo
-endif
-endif
+cat > foo.sh << 'END'
+#!/bin/sh
+exit 0
 END
+chmod a+x foo.sh
+
+cp foo.sh bar.test
+cp foo.sh sub/1.sh
+cp foo.sh sub/2.bar
+cp foo.sh sub/3.x
+
+do_setup ()
+{
+  ./configure "$@"
+  $MAKE check
+  ls -l . sub
+}
+
+do_clean ()
+{
+  $MAKE clean
+  test "$(find . -name '*.log')" = ./config.log
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+do_setup cond1=yes cond2=yes
+test -f foo.log
+test -f bar.test.log
+test -f sub/1.log
+test -f sub/2.bar.log
+test -f sub/3.x.log
+do_clean
+
+do_setup cond1=yes cond2=no
+test -f foo.log
+test -f bar.test.log
+test -f sub/1.log
+test -f sub/2.bar.log
+test -f sub/3.log
+do_clean
 
-: > test-driver
+do_setup cond1=no cond2=yes
+test -f foo.sh.log
+test -f bar.log
+test -f sub/1.log
+test -f sub/2.log
+test -f sub/3.x.log
+do_clean
 
-for i in 1 2 3; do
-  AUTOMAKE_fails $i
-  lineno=`sed -n 's/^## lineno //p' $i.am` \
-    && test 0 -lt "$lineno" \
-    || Exit 99
-  grep "^$i\\.am:$lineno:.*TEST_EXTENSIONS.*conditional content" stderr
-done
+do_setup cond1=no cond2=no
+test -f foo.sh.log
+test -f bar.log
+test -f sub/1.log
+test -f sub/2.log
+test -f sub/3.x.log
+do_clean
 
 :
-- 
1.7.9.5




reply via email to

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