]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] serial-tests: simplify automake-time preprocessing
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 21 May 2012 20:23:56 +0000 (22:23 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 22 May 2012 11:43:11 +0000 (13:43 +0200)
Prefer make-time and recipe-time processing instead.  Note that this
change does not (nor is meant to) offer any simplification nor performance
enhancement (in fact, it actually complicates the code); its purpose is
to continue the trend of "move logic and knowledge out of the automake
script and into the generated Makefiles".

* NG-NEWS: Report that $(TESTS) and $(XFAIL_TESTS) are not rewritten
anymore for $(EXEEXT) appending.
* automake.in (handle_tests): Don't rewrite TESTS nor XFAIL_TESTS
anymore.
* lib/am/check.am: If 'EXEEXT' AC_SUBST is used, process $(TESTS) and
$(XFAIL_TESTS) for $(EXEEXT) appending (for entries that are also
compiled programs).  Do so with the help of ...
(am__check_cook_with_exeext_1, am__check_cook_with_exeext): ... this
new internal make functions, and place the processed content into
(am__cooked_tests, am__cooked_xfail_tests): ... these new internal
variables respectively.
(check-TESTS): Depend on and use $(am__cooked_tests) rather than
plain $(TESTS).  While we are at it, remove some code duplication
with the help of the new 'is_xfail_test' shell function.
* t/check5.sh: Adjust and extend.
* t/check7.sh: Likewise.
* t/serial-tests.sh: Adjust.
* t/exeext4.sh: Adjust.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
NG-NEWS
automake.in
lib/am/check.am
t/check5.sh
t/check7.sh
t/exeext4.sh
t/serial-tests.sh

diff --git a/NG-NEWS b/NG-NEWS
index 2fbc0e4c28bcbb52948a6fe5e852a6b988ddf7f0..74b0721ac887b9a0a00dfa36983850ffb8cc2af0 100644 (file)
--- a/NG-NEWS
+++ b/NG-NEWS
@@ -59,6 +59,14 @@ Warnings and diagnostic
 * The 'portability-recursive' warning category is obsolete, and has been
   removed.
 
+Serial testsuite harness (obsolescent)
+======================================
+
+* The $(TESTS) and $(XFAIL_TESTS) variables are not anymore rewritten for
+  $(EXEEXT) appending.  The use of compiled programs in $(TESTS) and
+  $(XFAIL_TESTS) still works as before though, even on systems where
+  $(EXEEXT) is non-empty.
+
 Parallel testsuite harness
 ==========================
 
index 20197348450eea58d219427a109132aeac30eaa0..6b49543823efa07a80c36e6847d3427e01a5c202 100644 (file)
@@ -4637,11 +4637,7 @@ sub handle_tests
                                        CHECK_DEPS => "@check");
       if (option 'serial-tests')
         {
-          # Tests that are known programs should have $(EXEEXT) appended.
-          # For matching purposes, we need to adjust XFAIL_TESTS as well.
-          append_exeext { exists $known_programs{$_[0]} } 'TESTS';
-          append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS'
-           if (var ('XFAIL_TESTS'));
+          1; # Nothing to do, for now.
         }
       else
         {
index 45bc61567cb7577f92c743823d9a85b864447a16..782fdd6ca84d329f6637468985a022b76ec25937 100644 (file)
@@ -371,11 +371,33 @@ else %?SERIAL_TESTS%
 
 ## Obsolescent serial testsuite driver.
 
-check-TESTS: $(TESTS)
+if %?HANDLE-EXEEXT%
+## This is suboptimal, but we need to preserve the order of $(TESTS).
+am__check_cook_with_exeext_1 = \
+    $(if $(filter $(am__all_progs), $1), $1$(EXEEXT), $1)
+am__check_cook_with_exeext = $(strip \
+  $(if $(EXEEXT), $(foreach am__t, $1, $(call $(0)_1, $(am__t))), $1))
+else !%?HANDLE-EXEEXT%
+am__check_cook_with_exeext = $(strip $1)
+endif !%?HANDLE-EXEEXT%
+
+# TESTS can contain compiled programs, in which case we might have
+# to account for $(EXEEXT) appending.  For matching purposes, we
+# need to adjust XFAIL_TESTS as well.
+am__cooked_tests = $(call am__check_cook_with_exeext, $(TESTS))
+am__cooked_xfail_tests = $(call am__check_cook_with_exeext, $(XFAIL_TESTS))
+
+check-TESTS: $(am__cooked_tests)
        @failed=0; all=0; xfail=0; xpass=0; skip=0; \
        srcdir=$(srcdir); export srcdir; \
-       list='$(TESTS)'; \
+       list='$(am__cooked_tests)'; \
        $(am__tty_colors); \
+       is_xfail_test () { \
+         case " $(strip $(am__cooked_xfail_tests)) " in \
+           *" $$tst "*) return 0;; \
+           *) return 1;; \
+         esac; \
+       }; \
        if test -n "$$list"; then \
          for tst in $$list; do \
            if test -f ./$$tst; then dir=./; \
@@ -383,29 +405,23 @@ check-TESTS: $(TESTS)
            if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
 ## Success
              all=`expr $$all + 1`; \
-             case " $(XFAIL_TESTS) " in \
-             *[\ \     ]$$tst[\ \      ]*) \
+             if is_xfail_test; then \
                xpass=`expr $$xpass + 1`; \
                failed=`expr $$failed + 1`; \
                col=$$red; res=XPASS; \
-             ;; \
-             *) \
+             else \
                col=$$grn; res=PASS; \
-             ;; \
-             esac; \
+             fi; \
            elif test $$? -ne 77; then \
 ## Failure
              all=`expr $$all + 1`; \
-             case " $(XFAIL_TESTS) " in \
-             *[\ \     ]$$tst[\ \      ]*) \
+             if is_xfail_test; then \
                xfail=`expr $$xfail + 1`; \
                col=$$lgn; res=XFAIL; \
-             ;; \
-             *) \
+             else \
                failed=`expr $$failed + 1`; \
                col=$$red; res=FAIL; \
-             ;; \
-             esac; \
+             fi; \
            else \
 ## Skipped
              skip=`expr $$skip + 1`; \
index 56504283deb46b9b473899b1bb498359992dcc01..2e5e792f26abf6dbc68bf93fe25f24f2e40530c8 100755 (executable)
@@ -32,9 +32,15 @@ check-local:
        test -f one$(EXEEXT)
        test -f two$(EXEEXT)
        touch ok
-.PHONY: print-tests
-print-tests:
-       echo BEG: $(TESTS) :END
+prepare-for-fake-exeext:
+       rm -f ok
+       mv -f one$(EXEEXT) one.bin
+       mv -f two$(EXEEXT) two.bin
+post-check-for-fake-exeext:
+       test -f ok
+       test ! -f one$(EXEEXT)
+       test ! -f two$(EXEEXT)
+.PHONY: prepare-for-fake-exeext post-check-for-fake-exeext
 END
 
 $ACLOCAL
@@ -50,13 +56,15 @@ END
 cp one.c two.c
 
 ./configure
+
 $MAKE check
 test -f ok
-$MAKE EXEEXT=.bin print-tests >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEG: one.bin two.bin :END' stdout
-# No am__EXEEXT_* variable is needed.
-grep '_EXEEXT_[1-9]' Makefile.in && Exit 1
-$FGREP 'TESTS = $(check_PROGRAMS)' Makefile.in
+
+$MAKE prepare-for-fake-exeext
+$MAKE check EXEEXT=.bin
+$MAKE post-check-for-fake-exeext
+
+# No TESTS rewriting has taken place.
+grep '^TESTS = \$(check_PROGRAMS)$' Makefile.in
 
 :
index 5e4cafb38f1d36d43c443862c1eff20ebc3fb390..184ceb4a119db0497e7406da7067053d4d9129f5 100755 (executable)
@@ -30,11 +30,22 @@ TESTS = $(XFAIL_TESTS)
 XFAIL_TESTS = a b c d
 check_PROGRAMS = a c d
 check_SCRIPTS = b
+EXTRA_PROGRAMS = new old
 EXTRA_DIST = $(check_SCRIPTS)
 
-.PHONY: print-xfail-tests
-print-xfail-tests:
-       @echo BEG: $(XFAIL_TESTS) :END
+prepare-for-fake-exeext:
+       rm -f out.new out.old
+       touch a.fake c.fake d.fake
+       mv -f new$(EXEEXT) new.fake
+       mv -f old$(EXEEXT) old.fake
+post-check-for-fake-exeext:
+       test -f new.fake
+       test -f old.fake
+       test ! -f new
+       test ! -f new$(EXEEXT)
+       test ! -f old
+       test ! -f old$(EXEEXT)
+.PHONY: prepare-for-fake-exeext post-check-for-fake-exeext
 END
 
 cat > b <<'END'
@@ -54,6 +65,26 @@ END
 cp a.c c.c
 cp a.c d.c
 
+cat > new.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  FILE *fp = fopen ("out.new", "w");
+  fprintf (fp, "%s!\n", "Hello, Brave New World");
+  return (fclose (fp) != 0);
+}
+END
+
+cat > old.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  FILE *fp = fopen ("out.old", "w");
+  fprintf (fp, "%s!\n", "Hello, Europe");
+  return (fclose (fp) == 0);
+}
+END
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
@@ -61,11 +92,15 @@ $AUTOMAKE -a
 ./configure
 $MAKE check
 
-if test x"$am_serial_tests" = x"yes"; then
-  $MAKE EXEEXT=.bin print-xfail-tests >stdout || { cat stdout; Exit 1; }
-  cat stdout
-  $FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
-fi
+$MAKE check TESTS='old new' XFAIL_TESTS=old
+grep 'Hello, Brave New World!' out.new
+grep 'Hello, Europe!' out.old
+
+$MAKE prepare-for-fake-exeext
+$MAKE check TESTS='old new' EXEEXT=.fake XFAIL_TESTS=old
+$MAKE post-check-for-fake-exeext
+grep 'Hello, Brave New World!' out.new
+grep 'Hello, Europe!' out.old
 
 $MAKE distcheck
 
index a8595e3342a3b8f4ad743920b159a7f6bd64a369..9d64b70d3cc1b63daa65f9db1553fc0060b42e91 100755 (executable)
@@ -37,18 +37,18 @@ if COND
   BAZ = baz $(DEP)
 endif
 bin_PROGRAMS = $(programs) @programs@ prg3 $(BAR) $(BAZE)
+sbin_PROGRAMS = prg4 $(BAZ)
 EXTRA_PROGRAMS = prg1 prg2 prg3
-TESTS = prg1 prg3 prg4 $(BAZ)
 
 .PHONY: test-cond test-nocond
 test-nocond:
        is $(bin_PROGRAMS) == prg1.x prg2.x prg1.x prg2.x prg3.x
        is $(EXTRA_PROGRAMS) == prg1.x prg2.x prg3.x
-       is $(TESTS) == prg1.x prg3.x prg4
+       is $(sbin_PROGRAMS) == prg4.x
 test-cond:
        is $(bin_PROGRAMS) == prg1.x prg2.x prg1.x prg2.x prg3.x bar.x baz.x
        is $(EXTRA_PROGRAMS) == prg1.x prg2.x prg3.x
-       is $(TESTS) == prg1.x prg3.x prg4 baz.x bar.x
+       is $(sbin_PROGRAMS) == prg4.x baz.x bar.x
        is $(BAR) $(BAZ) == bar baz bar
 END
 
index 3825f70454fc213742532b74838c19d2cb31d0c4..353d94cc81959ec22bb0849cdae45319c0e6b1c8 100755 (executable)
@@ -23,7 +23,7 @@ hasnt_parallel_tests ()
 {
   $EGREP -i 'test_suite_log|test_(logs|bases)|\.log.*:' $1 && Exit 1
   grep 'recheck.*:' $1 && Exit 1
-  grep '^check-TESTS: \$(TESTS)$' $1
+  grep '^check-TESTS: \$(am__cooked_tests)$' $1
 }
 
 has_parallel_tests ()