automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Testsuite: use $SHELL to run tests which are shell scripts.


From: Stefano Lattarini
Subject: Re: [PATCH] Testsuite: use $SHELL to run tests which are shell scripts.
Date: Mon, 3 Jan 2011 16:04:26 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

References:
 <http://lists.gnu.org/archive/html/automake-patches/2010-12/msg00010.html>
 <http://lists.gnu.org/archive/html/automake-patches/2010-09/msg00004.html>

-*-*-

Hello automakers.
 
I have rebased the patch on latest master again.  I'll wait until *sunday*
evening before pushing to master.

That said, even if the patch is pretty simple, it's not completely obvious,
and a review before I push it would be very welcome.

Regards,
  Stefano
From 0aeda2e829eba6902e2016eb0950c5acf1cdf2c4 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 3 Dec 2010 15:24:14 +0100
Subject: [PATCH] Testsuite: use $SHELL to run tests which are shell scripts.

* tests/Makefile.am (TEST_LOG_COMPILER): Define so that the
configure-time $SHELL is used to run the tests.
(TEST_EXTENSIONS): Defined to `.test', for clarity.
* tests/defs: Add code to re-execute by default the running
test script with configure-time $SHELL.  Updated comments.
* configure.ac: Check that `set -e' is working for $SHELL,
not for /bin/sh.
* tests/defs-static.in: Update comments.
* tests/README (Supported shells): Updated.
(Getting details from failures): Don't tell that tests are
run by /bin/sh by default.
---
 ChangeLog            |   15 ++++++++++++++
 configure            |    6 ++--
 configure.ac         |    4 +-
 tests/Makefile.am    |    6 +++++
 tests/Makefile.in    |    6 ++++-
 tests/README         |   19 +++++++++++++----
 tests/defs           |   53 +++++++++++++++++++++++++++++++++++++++++++++++--
 tests/defs-static.in |    9 ++++++-
 8 files changed, 102 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 472dc55..9df7952 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-03  Stefano Lattarini  <address@hidden>
+
+       Testsuite: use $SHELL to run tests which are shell scripts.
+       * tests/Makefile.am (TEST_LOG_COMPILER): Define so that the
+       configure-time $SHELL is used to run the tests.
+       (TEST_EXTENSIONS): Defined to `.test', for clarity.
+       * tests/defs: Add code to re-execute by default the running
+       test script with configure-time $SHELL.  Updated comments.
+       * configure.ac: Check that `set -e' is working for $SHELL,
+       not for /bin/sh.
+       * tests/defs-static.in: Update comments.
+       * tests/README (Supported shells): Updated.
+       (Getting details from failures): Don't tell that tests are
+       run by /bin/sh by default.
+
 2011-01-02  Ralf Wildenhues  <address@hidden>
 
        Sync auxiliary files from upstream.
diff --git a/configure b/configure
index 089b32a..6b39e49 100755
--- a/configure
+++ b/configure
@@ -2757,12 +2757,12 @@ $as_echo "$ac_cv_path_FGREP" >&6; }
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /bin/sh has working 
'set -e' with exit trap" >&5
-$as_echo_n "checking whether /bin/sh has working 'set -e' with exit trap... " 
>&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $SHELL has working 
'set -e' with exit trap" >&5
+$as_echo_n "checking whether $SHELL has working 'set -e' with exit trap... " 
>&6; }
 if ${am_cv_sh_errexit_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if /bin/sh -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
+  if $SHELL -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
 then
   am_cv_sh_errexit_works=yes
 else
diff --git a/configure.ac b/configure.ac
index 577541c..8af0b60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,9 +177,9 @@ AC_SUBST([MODIFICATION_DELAY])
 AC_PROG_EGREP
 AC_PROG_FGREP
 
-AC_CACHE_CHECK([whether /bin/sh has working 'set -e' with exit trap],
+AC_CACHE_CHECK([whether $SHELL has working 'set -e' with exit trap],
 [am_cv_sh_errexit_works],
-[if /bin/sh -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
+[if $SHELL -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77
 then
   am_cv_sh_errexit_works=yes
 else
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ea0b64a..3eedd43 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,12 @@
 MAINTAINERCLEANFILES =
 EXTRA_DIST = ChangeLog-old
 
+TEST_EXTENSIONS = .test
+# Run the tests with the shell detected at configure time.  Also, tell
+# them not to needlessly re-execute themselves with that shell, since
+# we know they are already running under it in our setup.
+TEST_LOG_COMPILER = AM_TESTS_REEXEC=no $(SHELL)
+
 XFAIL_TESTS = \
 all.test \
 auxdir2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 9e78c97..68bdae5 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -183,7 +183,6 @@ RECHECK_LOGS = $(TEST_LOGS)
 AM_RECURSIVE_TARGETS = check check-html recheck recheck-html
 TEST_SUITE_LOG = test-suite.log
 TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
-TEST_EXTENSIONS = .test
 am__test_logs1 = $(TESTS:=.log)
 TEST_LOGS = $(am__test_logs1:.test.log=.log)
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
@@ -284,6 +283,11 @@ top_srcdir = @top_srcdir@
 MAINTAINERCLEANFILES = $(parallel_tests) $(instspc_tests)
 EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
        $(TESTS)
+TEST_EXTENSIONS = .test
+# Run the tests with the shell detected at configure time.  Also, tell
+# them not to needlessly re-execute themselves with that shell, since
+# we know they are already running under it in our setup.
+TEST_LOG_COMPILER = AM_TESTS_REEXEC=no $(SHELL)
 XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \
        override-conditional-2.test txinfo5.test \
        $(instspc_xfail_tests)
diff --git a/tests/README b/tests/README
index 1369bd3..229f6af 100644
--- a/tests/README
+++ b/tests/README
@@ -51,10 +51,10 @@ Interpretation
 Getting details from failures
 -----------------------------
 
-  Each test is a shell script, and by default is run by /bin/sh.
-  In a non-VPATH build you can run them directly, they will be verbose.
-  By default, verbose output of a test foo.test is retained in the log
-  file foo.log.  A summary log is created in the file test-suite.log.
+  Each test is a shell script.  In a non-VPATH build you can run the
+  tests directly, they will be verbose.  By default, verbose output of
+  a test foo.test is retained in the log file foo.log.  A summary log
+  is created in the file test-suite.log.
 
   You can limit the set of files using the TESTS variable, and enable
   detailed test output at the end of the test run with the VERBOSE
@@ -66,6 +66,15 @@ Getting details from failures
 Supported shells
 ----------------
 
+  By default, the tests are run by the $SHELL detected at configure
+  time.  They also take care to re-execute themselves with that shell,
+  unless told not to.  So, to run the tests with a different shell, say
+  `/path/to/sh', the user must resort to something like:
+    $ AM_TESTS_REEXEC=no /path/to/sh ./foo.test
+  to run a test directly, and something like:
+    $ AM_TESTS_REEXEC=no make check TEST_LOG_COMPILER=/path/to/sh
+  to run the test(s) through the makefile test driver.
+
   The test scripts are written with portability in mind, so that they
   should run with any decent Bourne-compatible shell.
 
@@ -77,7 +86,7 @@ Supported shells
   version of Zsh is used.  Thus, if you want to run a test script, say
   foo.test, with Zsh 4.2, you *can't* simply do `zsh foo.test', but
   you *must* resort to:
-    zsh -o no_function_argzero foo.test
+    AM_TESTS_REEXEC=no zsh -o no_function_argzero foo.test
 
   Note that this problem does not occur if Zsh is executed through
   a symlink with a basename of `sh', since in that case Zsh starts
diff --git a/tests/defs b/tests/defs
index f04a756..de85338 100644
--- a/tests/defs
+++ b/tests/defs
@@ -16,6 +16,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+
+# IMPORTANT NOTE: This file should execute correctly with any system's
+# /bin/sh shell, and not only with configure-time detected $CONFIG_SHELL,
+# until differently and explicitly specified.
+
+
 ## -------------------------------------------------------- ##
 ##  Source static setup and definitions for the testsuite.  ##
 ## -------------------------------------------------------- ##
@@ -33,9 +39,9 @@ test -f ./defs-static || {
 me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'`
 
 
-## ---------------------------------------- ##
-##  Sanity checks and environment cleanup.  ##
-## ---------------------------------------- ##
+## ---------------------- ##
+##  Early sanity checks.  ##
+## ---------------------- ##
 
 # Ensure $testsrcdir is set correctly.
 test -f "$testsrcdir/defs-static.in" || {
@@ -49,6 +55,47 @@ test -f "$testbuilddir/defs-static" || {
    exit 1
 }
 
+# Ensure we can find ourselves.
+test -f "$0" || {
+   echo "$me: unable to find myself: $0" >&2
+   exit 1
+}
+
+
+## ------------------------------------ ##
+##  Ensure we run with a proper shell.  ##
+## ------------------------------------ ##
+
+# Make sure we run with the shell detected at configure time (unless
+# the user forbids it).
+case ${AM_TESTS_REEXEC-yes} in
+  1|[yY]|[yY]es)
+    AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+    # Cannot simply do `opts=$-', since the content of $- is not
+    # portable among different shells.  So try to propagate only
+    # the portable and interesting options.
+    case $- in
+      *x*v*|*v*x) opts=-vx;;
+      *v*) opts=-v;;
+      *x*) opts=-x;;
+      *) opts=;;
+    esac
+    echo $me: exec $SHELL $opts "$0" "$*"
+    exec $SHELL $opts "$0" ${1+"$@"}
+    # NOTREACHED
+    echo "$me: failed to re-execute with $SHELL" >&2
+    exit 99
+    ;;
+esac
+
+# NOTE: From this point on, we can assume this file is being executed
+# by the configure-time detected $CONFIG_SHELL.
+
+
+## ---------------------- ##
+##  Environment cleanup.  ##
+## ---------------------- ##
+
 # Unset some MAKE... variables that may cause $MAKE to act like a
 # recursively invoked sub-make.  Any $MAKE invocation in a test is
 # conceptually an independent invocation, not part of the main
diff --git a/tests/defs-static.in b/tests/defs-static.in
index 9143178..7e399f3 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -16,9 +16,14 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 
 # Defines and minimal setup for Automake testing environment.
-# IMPORTANT: Multiple inclusions of this file should be idempotent!
+
+# IMPORTANT NOTES AND REQUIREMENTS
+#   - Multiple inclusions of this file should be idempotent.
+#   - This file should execute correctly with any system's /bin/sh
+#     shell, not only with configure-time detected $CONFIG_SHELL.
 
 # Be more Bourne compatible.
 # (Snippet inspired to configure's initialization in Autoconf 2.64)
@@ -115,7 +120,7 @@ FGREP='@FGREP@'
 # this variable.
 TEX='@TEX@'
 
-# Whether /bin/sh has working 'set -e' with exit trap.
+# Whether $SHELL has working 'set -e' with exit trap.
 sh_errexit_works='@sh_errexit_works@'
 
 # The amount we should wait after modifying files depends on the platform.
-- 
1.7.2.3


reply via email to

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