automake-patches
[Top][All Lists]
Advanced

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

[FYI] {testsuite-work} testsuite: avoid generating `*-p.test' tests, use


From: Stefano Lattarini
Subject: [FYI] {testsuite-work} testsuite: avoid generating `*-p.test' tests, use a wrapper script
Date: Wed, 1 Jun 2011 16:37:42 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

The generated `*-p.test' tests had already become just thin layers
around the corresponding test scripts.  This change makes the final
step, converting to the use of a generic wrapper script and thus
avoiding the extra test generation (similarly to what is done for
the `*.instspc' and `*.depmod' tests).

* tests/parallel-tests.sh: New file, driver script to run checks
the on the `parallel-tests' semantics by wrapping tests that use
the generic "Simple Tests" driver.
* tests/gen-parallel-tests: Update, mostly to reflect the new
`.ptest' extensions used for tests in $(parallel_tests).
* Makefile.am (TESTS_EXTENSIONS): Add `.ptest'.
(PTEST_LOG_COMPILER): Define, it calls `parallel-tests.sh'.
($(parallel_tests)): Do not really generate `*-p.test' tests
anymore; this is now just a dummy dependency declaration required
in order to have make actually produce expected log files from
the `.ptest.log' suffix rule.
(EXTRA_DIST): Distribute `parallel-tests.sh'.
(MAINTAINERCLEANFILES): Don't remove the `$(parallel_tests)', it
is not necessary anymore.
(generated_tests): Variable definition removed.
(TESTS): Update, by listing `$(parallel_tests)' directly instead
of `$(generated_tests)'
(expected_list_of_tests): Remove `$(generated_tests)'.
(maintainer-check-list-of-tests): No need to explicitly depend on
`$(expected_list_of_tests)' anymore.
---
 ChangeLog                |   29 +++++++++++++++++++
 tests/Makefile.am        |   41 ++++++++-------------------
 tests/Makefile.in        |   69 +++++++++++++++++++--------------------------
 tests/gen-parallel-tests |    7 ++--
 tests/parallel-tests.sh  |   52 ++++++++++++++++++++++++++++++++++
 5 files changed, 125 insertions(+), 73 deletions(-)
 create mode 100755 tests/parallel-tests.sh

diff --git a/ChangeLog b/ChangeLog
index 281afa2..bf7fb8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2011-06-01  Stefano Lattarini  <address@hidden>
+
+       testsuite: avoid generating `*-p.test' tests, use a wrapper script
+       The generated `*-p.test' tests had already become just thin layers
+       around the corresponding test scripts.  This change makes the final
+       step, converting to the use of a generic wrapper script and thus
+       avoiding the extra test generation (similarly to what is done for
+       the `*.instspc' and `*.depmod' tests).
+       * tests/parallel-tests.sh: New file, driver script to run checks
+       the on the `parallel-tests' semantics by wrapping tests that use
+       the generic "Simple Tests" driver.
+       * tests/gen-parallel-tests: Update, mostly to reflect the new
+       `.ptest' extensions used for tests in $(parallel_tests).
+       * Makefile.am (TESTS_EXTENSIONS): Add `.ptest'.
+       (PTEST_LOG_COMPILER): Define, it calls `parallel-tests.sh'.
+       ($(parallel_tests)): Do not really generate `*-p.test' tests
+       anymore; this is now just a dummy dependency declaration required
+       in order to have make actually produce expected log files from
+       the `.ptest.log' suffix rule.
+       (EXTRA_DIST): Distribute `parallel-tests.sh'.
+       (MAINTAINERCLEANFILES): Don't remove the `$(parallel_tests)', it
+       is not necessary anymore.
+       (generated_tests): Variable definition removed.
+       (TESTS): Update, by listing `$(parallel_tests)' directly instead
+       of `$(generated_tests)'
+       (expected_list_of_tests): Remove `$(generated_tests)'.
+       (maintainer-check-list-of-tests): No need to explicitly depend on
+       `$(expected_list_of_tests)' anymore.
+
 2011-05-29  Stefano Lattarini  <address@hidden>
 
        automake, aclocal: honour configure-time AUTOCONF and AUTOM4TE
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3d1e5c4..a7958d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,31 +38,17 @@ include $(srcdir)/parallel-tests.am
 
 $(srcdir)/parallel-tests.am: gen-parallel-tests Makefile.am
        $(AM_V_GEN)($(am__cd) $(srcdir) && $(SHELL) ./gen-parallel-tests) >$@
+EXTRA_DIST += gen-parallel-tests
 
-$(parallel_tests): Makefile.am
-       $(AM_V_at)rm -f $@ address@hidden
-       $(AM_V_GEN)input=`echo $@ | sed 's,.*/,,; s,-p.test$$,.test,'`; \
-       { echo '#!/bin/sh'; \
-         echo '# DO NOT EDIT!  GENERATED AUTOMATICALLY!'; \
-         echo; \
-         echo '# Ensure proper definition of $$testsrcdir.'; \
-         echo '. ./defs-static || exit 99'; \
-         echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \
-         echo; \
-         echo "# Run the test with Automake's parallel-tests driver enabled."; 
\
-         echo 'parallel_tests=yes'; \
-         echo "# In the spirit of VPATH, we prefer a test in the build tree"; \
-         echo "# over one in the source tree."; \
-         echo "if test -f \"./$$input\"; then"; \
-         echo "  . \"./$$input\""; \
-         echo 'else'; \
-         echo "  . \"\$$testsrcdir/$$input\""; \
-         echo 'fi'; \
-       } > address@hidden
-       $(AM_V_at)chmod a+rx address@hidden && mv -f address@hidden $@
+TEST_EXTENSIONS += .ptest
+PTEST_LOG_COMPILER = $(SHELL) $(srcdir)/parallel-tests.sh
+EXTRA_DIST += parallel-tests.sh
 
-MAINTAINERCLEANFILES += $(parallel_tests)
-EXTRA_DIST += gen-parallel-tests
+# All `*-p.ptest' tests work by sourcing the script `parallel-tests.sh'.
+$(parallel_tests:.ptest=.log): parallel-tests.sh
+# This dummy declaration is required to have make actually produce
+# expected log files from the `.ptest.log' suffix rule.
+$(parallel_tests):
 
 
 include $(srcdir)/instspc-tests.am
@@ -126,13 +112,11 @@ AM_TESTS_ENVIRONMENT = \
 
 TESTS = \
   $(handwritten_tests) \
-  $(generated_tests) \
+  $(parallel_tests) \
   $(depmod_tests) \
   $(instspc_tests)
 
-EXTRA_DIST += $(handwritten_tests) $(generated_tests)
-
-generated_tests = $(parallel_tests)
+EXTRA_DIST += $(handwritten_tests)
 
 handwritten_tests = \
 aclocal.test \
@@ -1084,9 +1068,8 @@ yflags-var-expand.test
 
 ## Checking the test of tests.
 checked_test_extensions = .test
-expected_list_of_tests = $(handwritten_tests) $(generated_tests)
+expected_list_of_tests = $(handwritten_tests)
 include $(top_srcdir)/CheckListOfTests.am
-maintainer-check-list-of-tests: $(expected_list_of_tests)
 
 # Dependencies valid for each test case.
 $(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
diff --git a/tests/Makefile.in b/tests/Makefile.in
index e9f49bb..4279eea 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -192,10 +192,13 @@ am__test_logs1 = $(TESTS:=.log)
 am__test_logs2 = $(am__test_logs1:.test.log=.log)
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
        $(TEST_LOG_FLAGS)
-am__test_logs3 = $(am__test_logs2:.instspc.log=.log)
+am__test_logs3 = $(am__test_logs2:.ptest.log=.log)
+PTEST_LOG_COMPILE = $(PTEST_LOG_COMPILER) $(AM_PTEST_LOG_FLAGS) \
+       $(PTEST_LOG_FLAGS)
+am__test_logs4 = $(am__test_logs3:.instspc.log=.log)
 INSTSPC_LOG_COMPILE = $(INSTSPC_LOG_COMPILER) $(AM_INSTSPC_LOG_FLAGS) \
        $(INSTSPC_LOG_FLAGS)
-TEST_LOGS = $(am__test_logs3:.depmod.log=.log)
+TEST_LOGS = $(am__test_logs4:.depmod.log=.log)
 DEPMOD_LOG_COMPILE = $(DEPMOD_LOG_COMPILER) $(AM_DEPMOD_LOG_FLAGS) \
        $(DEPMOD_LOG_FLAGS)
 TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
@@ -298,24 +301,26 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-MAINTAINERCLEANFILES = $(parallel_tests)
-EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
-       depmod-tests.sh $(handwritten_tests) $(generated_tests)
-TEST_EXTENSIONS = .test .instspc .depmod
+MAINTAINERCLEANFILES = 
+EXTRA_DIST = ChangeLog-old gen-parallel-tests parallel-tests.sh \
+       instspc-tests.sh depmod-tests.sh $(handwritten_tests)
+TEST_EXTENSIONS = .test .ptest .instspc .depmod
 # Run the tests with the shell detected at configure time.
 TEST_LOG_COMPILER = $(SHELL)
 XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \
        override-conditional-2.test pr8365-remake-timing.test \
        yacc-dist-nobuild-subdir.test txinfo5.test \
        $(instspc_xfail_tests)
-parallel_tests = backcompat5-p.test check-exported-srcdir-p.test \
-       check-subst-prog-p.test check-subst-p.test \
-       check-tests-in-builddir-p.test check-tests_environment-p.test \
-       check-p.test check10-p.test check11-p.test check12-p.test \
-       check2-p.test check3-p.test check4-p.test check5-p.test \
-       check6-p.test check7-p.test check8-p.test color-p.test \
-       color2-p.test comment9-p.test dejagnu-p.test exeext4-p.test \
-       maken3-p.test maken4-p.test posixsubst-tests-p.test
+parallel_tests = backcompat5-p.ptest check-exported-srcdir-p.ptest \
+       check-subst-prog-p.ptest check-subst-p.ptest \
+       check-tests-in-builddir-p.ptest \
+       check-tests_environment-p.ptest check-p.ptest check10-p.ptest \
+       check11-p.ptest check12-p.ptest check2-p.ptest check3-p.ptest \
+       check4-p.ptest check5-p.ptest check6-p.ptest check7-p.ptest \
+       check8-p.ptest color-p.ptest color2-p.ptest comment9-p.ptest \
+       dejagnu-p.ptest exeext4-p.ptest maken3-p.ptest maken4-p.ptest \
+       posixsubst-tests-p.ptest
+PTEST_LOG_COMPILER = $(SHELL) $(srcdir)/parallel-tests.sh
 instspc_tests = build-squote.instspc install-squote.instspc \
        build-dquote.instspc install-dquote.instspc \
        build-bquote.instspc install-bquote.instspc \
@@ -397,11 +402,10 @@ AM_TESTS_ENVIRONMENT = \
 
 TESTS = \
   $(handwritten_tests) \
-  $(generated_tests) \
+  $(parallel_tests) \
   $(depmod_tests) \
   $(instspc_tests)
 
-generated_tests = $(parallel_tests)
 handwritten_tests = \
 aclocal.test \
 aclocal3.test \
@@ -1350,14 +1354,14 @@ yflags-force-conditional.test \
 yflags-var-expand.test
 
 checked_test_extensions = .test
-expected_list_of_tests = $(handwritten_tests) $(generated_tests)
+expected_list_of_tests = $(handwritten_tests)
 am__tmk = tests-in-makefile-list.tmp
 am__tfs = tests-on-filesystem-list.tmp
 am__tdf = diff-in-tests-lists.tmp
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .depmod .html .instspc .log .test
+.SUFFIXES: .depmod .html .instspc .log .ptest .test
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/parallel-tests.am 
$(srcdir)/instspc-tests.am $(srcdir)/depmod-tests.am 
$(top_srcdir)/CheckListOfTests.am $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
@@ -1529,6 +1533,8 @@ recheck recheck-html:
        $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) 
TEST_LOGS="'"$$list"'"'
 .test.log:
        @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
+.ptest.log:
+       @p='$<'; $(am__check_pre) $(PTEST_LOG_COMPILE) "$$tst" $(am__check_post)
 .instspc.log:
        @p='$<'; $(am__check_pre) $(INSTSPC_LOG_COMPILE) "$$tst" 
$(am__check_post)
 .depmod.log:
@@ -1713,27 +1719,11 @@ posixsubst-tests-p.log: posixsubst-tests.test
 $(srcdir)/parallel-tests.am: gen-parallel-tests Makefile.am
        $(AM_V_GEN)($(am__cd) $(srcdir) && $(SHELL) ./gen-parallel-tests) >$@
 
-$(parallel_tests): Makefile.am
-       $(AM_V_at)rm -f $@ address@hidden
-       $(AM_V_GEN)input=`echo $@ | sed 's,.*/,,; s,-p.test$$,.test,'`; \
-       { echo '#!/bin/sh'; \
-         echo '# DO NOT EDIT!  GENERATED AUTOMATICALLY!'; \
-         echo; \
-         echo '# Ensure proper definition of $$testsrcdir.'; \
-         echo '. ./defs-static || exit 99'; \
-         echo 'test -n "$$testsrcdir" || exit 99 # sanity check'; \
-         echo; \
-         echo "# Run the test with Automake's parallel-tests driver enabled."; 
\
-         echo 'parallel_tests=yes'; \
-         echo "# In the spirit of VPATH, we prefer a test in the build tree"; \
-         echo "# over one in the source tree."; \
-         echo "if test -f \"./$$input\"; then"; \
-         echo "  . \"./$$input\""; \
-         echo 'else'; \
-         echo "  . \"\$$testsrcdir/$$input\""; \
-         echo 'fi'; \
-       } > address@hidden
-       $(AM_V_at)chmod a+rx address@hidden && mv -f address@hidden $@
+# All `*-p.ptest' tests work by sourcing the script `parallel-tests.sh'.
+$(parallel_tests:.ptest=.log): parallel-tests.sh
+# This dummy declaration is required to have make actually produce
+# expected log files from the `.ptest.log' suffix rule.
+$(parallel_tests):
 
 $(srcdir)/instspc-tests.am: instspc-tests.sh Makefile.am
        $(AM_V_GEN)($(am__cd) $(srcdir) \
@@ -1803,7 +1793,6 @@ maintainer-check-list-of-tests:
 clean-local: clean-maintcheck-testslist-tmp
 clean-maintcheck-testslist-tmp:
        rm -f $(am__tmk) $(am__tfs) $(am__tdf)
-maintainer-check-list-of-tests: $(expected_list_of_tests)
 
 # Dependencies valid for each test case.
 $(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
diff --git a/tests/gen-parallel-tests b/tests/gen-parallel-tests
index 0c96228..340b0e7 100755
--- a/tests/gen-parallel-tests
+++ b/tests/gen-parallel-tests
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # For each test in the TESTS list in this Makefile.am file, that itself
-# tests features of the TESTS automake interface, generate a sibling
+# tests features of the TESTS automake interface, define a sibling
 # test that does likewise, but with the option `parallel-tests' enabled.
 # Individual tests can prevent the creation of such a sibling by
 # explicitly setting the `$parallel_tests' variable to either "yes" or
@@ -41,7 +41,6 @@ fi
   grep -l '^TESTS ' $tests
   grep -l ' TESTS ' $tests
 } |
-grep -v '.-p\.test' |
 LC_ALL=C sort -u |
 while read tst; do
   if grep '^[^#]*parallel-tests' $tst >/dev/null \
@@ -52,12 +51,12 @@ sed -e 's/\.test$//' |
 {
   echo "## Generated by gen-parallel-tests.  Edit Makefile.am instead of this."
   echo "parallel_tests ="
-  # Since `foo-p.test' sources `foo.test', `foo-p.log' also depends on
+  # Since `foo-p.ptest' sources `foo.test', `foo-p.log' also depends on
   # `foo.test'.
   sed -e '
     h
     s/^/parallel_tests += /
-    s/$/-p.test/
+    s/$/-p.ptest/
     p
     x
     s/.*/&-p.log: &.test/
diff --git a/tests/parallel-tests.sh b/tests/parallel-tests.sh
new file mode 100755
index 0000000..b6bbff3
--- /dev/null
+++ b/tests/parallel-tests.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011 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 2, 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/>.
+
+# Driver script to run checks the on the `parallel-tests' semantics
+# by wrapping tests that use the generic "Simple Tests" driver.
+
+set -e
+
+fatal_ () { echo "$0: $*" >&2; exit 99; }
+
+# Ensure proper definition of $testsrcdir.
+. ./defs-static || exit 99
+test -n "$testsrcdir" || fatal_ "\$testsrcdir is empty or undefined"
+
+case $#,$1 in
+  0,) fatal_ "missing argument";;
+  1,*-p.ptest) test_name=`expr /"$1" : '.*/\(.*\)-p\.ptest'`;;
+  1,*) fatal_ "invalid argument \`$1'";;
+  *) fatal_ "too many arguments";;
+esac
+
+# Run the test with Automake's parallel-tests driver enabled.
+parallel_tests=yes
+# This is required to have the wrapped test use a proper temporary
+# directory to run into.
+me=$test_name-p
+# In the spirit of VPATH, we prefer a test in the build tree
+# over one in the source tree.
+if test -f "./$test_name.test"; then
+  . "./$test_name.test"
+  exit $?
+elif test -f "$testsrcdir/$test_name.test"; then
+  . "$testsrcdir/$test_name.test"
+  exit $?
+else
+  fatal_ "cannot find wrapped test \`$test_name.test'"
+fi
+
+exit 255 # Not reached.
-- 
1.7.2.3




reply via email to

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