+2011-05-27 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ 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.
+ * 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-05-26 Stefano Lattarini <stefano.lattarini@gmail.com>
tests: split 'subst2.test' to improve modularity and coverage
-{ $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
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
EXTRA_DIST = ChangeLog-old
TEST_EXTENSIONS = .test
+# Run the tests with the shell detected at configure time.
+TEST_LOG_COMPILER = $(SHELL)
XFAIL_TESTS = \
all.test \
# test scripts, but not from the environment.
# We want warning messages and explanations for skipped tests to go to
# the console if possible, so set up `stderr_fileno_' properly.
+# The `AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
+# re-execute themselves with the shell detected at configure time, since
+# we are already running them under it explicitly in our setup (see e.g.
+# the definition of TEST_LOG_COMPILER above).
AM_TESTS_ENVIRONMENT = \
test x"$$me" = x || unset me; \
test x"$$required" = x || unset required; \
test x"$$parallel_tests" = x || unset parallel_tests; \
test x"$$original_AUTOMAKE" = x || unset original_AUTOMAKE; \
test x"$$original_ACLOCAL" = x || unset original_ACLOCAL; \
+ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC; \
exec 9>&2; stderr_fileno_=9; export stderr_fileno_;
TESTS = \
EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
depmod-tests.sh $(handwritten_tests) $(generated_tests)
TEST_EXTENSIONS = .test .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 \
# test scripts, but not from the environment.
# We want warning messages and explanations for skipped tests to go to
# the console if possible, so set up `stderr_fileno_' properly.
+# The `AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
+# re-execute themselves with the shell detected at configure time, since
+# we are already running them under it explicitly in our setup (see e.g.
+# the definition of TEST_LOG_COMPILER above).
AM_TESTS_ENVIRONMENT = \
test x"$$me" = x || unset me; \
test x"$$required" = x || unset required; \
test x"$$parallel_tests" = x || unset parallel_tests; \
test x"$$original_AUTOMAKE" = x || unset original_AUTOMAKE; \
test x"$$original_ACLOCAL" = x || unset original_ACLOCAL; \
+ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC; \
exec 9>&2; stderr_fileno_=9; export stderr_fileno_;
TESTS = \
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
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/another/sh', the user must use:
+
+ AM_TESTS_REEXEC=no /path/to/another/sh ./foo.test
+
+ to run a test directly, and:
+
+ make check TEST_LOG_COMPILER=/path/to/sh (GNU make)
+ TEST_LOG_COMPILER=/path/to/sh make -e check (non-GNU make)
+
+ 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.
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
# 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. ##
## -------------------------------------------------------- ##
|| { echo "$argv0: failed to define \$me" >&2; exit 99; }
fi
-## ---------------------------------------- ##
-## Sanity checks and environment cleanup. ##
-## ---------------------------------------- ##
+## ---------------------- ##
+## Early sanity checks. ##
+## ---------------------- ##
# A single whitespace character.
sp=' '
exit 99
}
+# 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
+ n|no|false|0)
+ ;;
+ *)
+ 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+"$@"}
+ 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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Defines and minimal setup for Automake testing environment.
-# Multiple inclusions of this file should be idempotent!
-# This code needs to be 'set -e' clean.
+
+# IMPORTANT NOTES AND REQUIREMENTS
+# - Multiple inclusions of this file should be idempotent.
+# - This code has to be 'set -e' clean.
+# - 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)
# 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.