[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 02/17] [ng] serial-tests: simplify automake-time pr
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 02/17] [ng] serial-tests: simplify automake-time preprocessing |
Date: |
Tue, 22 May 2012 22:48:40 +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 <address@hidden>
---
NG-NEWS | 8 ++++++++
automake.in | 6 +-----
lib/am/check.am | 44 ++++++++++++++++++++++++++++++--------------
t/check5.sh | 26 +++++++++++++++++---------
t/check7.sh | 51 +++++++++++++++++++++++++++++++++++++++++++--------
t/exeext4.sh | 6 +++---
t/serial-tests.sh | 2 +-
7 files changed, 103 insertions(+), 40 deletions(-)
diff --git a/NG-NEWS b/NG-NEWS
index 2fbc0e4..74b0721 100644
--- 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
==========================
diff --git a/automake.in b/automake.in
index 2019734..6b49543 100644
--- a/automake.in
+++ b/automake.in
@@ -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
{
diff --git a/lib/am/check.am b/lib/am/check.am
index 45bc615..782fdd6 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -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`; \
diff --git a/t/check5.sh b/t/check5.sh
index 5650428..2e5e792 100755
--- a/t/check5.sh
+++ b/t/check5.sh
@@ -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
:
diff --git a/t/check7.sh b/t/check7.sh
index 5e4cafb..184ceb4 100755
--- a/t/check7.sh
+++ b/t/check7.sh
@@ -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
diff --git a/t/exeext4.sh b/t/exeext4.sh
index a8595e3..9d64b70 100755
--- a/t/exeext4.sh
+++ b/t/exeext4.sh
@@ -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
diff --git a/t/serial-tests.sh b/t/serial-tests.sh
index 3825f70..353d94c 100755
--- a/t/serial-tests.sh
+++ b/t/serial-tests.sh
@@ -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 ()
--
1.7.9.5
- [Automake-NG] [PATCH 00/17] Move almost parallel-tests processing at make runtime, Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 01/17] [ng] am: new private make variable $(am__all_progs), Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 02/17] [ng] serial-tests: simplify automake-time preprocessing,
Stefano Lattarini <=
- [Automake-NG] [PATCH 03/17] [ng] tests: get rid of an almost-obsolete test case (parallel-tests related), Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 04/17] [ng] am: implement $(am__tolower) and $(am__toupper), Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 05/17] [ng] refactor: make '$am_config_aux_dir' available as a make variable, Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 06/17] [ng] check: move definition of console colors in its own '.am' fragment, Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 07/17] [ng] check: separate serial an parallel harnesses in distinct '.am' files, Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 08/17] [ng] check: warn about invalid TEST_EXTENSIONS at make runtime, Stefano Lattarini, 2012/05/22
- [Automake-NG] [PATCH 09/17] [ng] check: unconditionally distribute test-driver, Stefano Lattarini, 2012/05/22