/t/wrap/automake-1.*
/defs-static
/t/testsuite-part.am
+/t/ax/test-runner
/t/*-w.tap
/t/*-w.sh
/t/depcomp-*.tap
; do \
eval test x"\$${$$v}" = x || unset $$v; \
done;
-# 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 += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
# We want warning messages and explanations for skipped tests to go to
# the console if possible, so set up 'stderr_fileno_' properly.
AM_TESTS_FD_REDIRECT = 9>&2
## ---------------------- ##
AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([t/ax/test-runner], [chmod +x t/ax/test-runner])
AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])
AC_CONFIG_LINKS([defs:defs])
# 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 (which
-# might be just a Bourne shell, non POSIX-conforming, like on Solaris
-# up to version 11 at least).
-
# Source the shell static setup and variable definitions.
-. ./defs-static
-test $? -eq 0 || exit 99
-
-# Make sure we run with the shell detected at configure time or forced
-# by the user (unless the user forbids it). That is assumed to be a
-# proper POSIX shell.
-case ${AM_TESTS_REEXEC-yes} in
- n|no|false|0)
- ;;
- *)
- # Ensure we can find ourselves.
- if test ! -f "$argv0"; then
- echo "$me: unable to find myself: '$argv0'" >&2
- exit 99
- fi
- 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 exec $AM_TEST_RUNNER_SHELL $opts "$argv0" "$*"
- exec $AM_TEST_RUNNER_SHELL $opts "$argv0" ${1+"$@"}
- # This should be dead code, unless some strange error happened.
- echo "$me: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
- exit 99
- ;;
-esac
+. ./defs-static; test $? -eq 0 || exit 99
# Source the actual test initialization and setup code, and return
# control to the test script that is sourcing us.
There are two kinds of tests in the Automake testsuite (both implemented
as shell scripts). The scripts with the '.sh' suffix are "simple"
tests, their outcome completely determined by their exit status. Those
- with the '.tap' suffix use the TAP protocol. If you want to run a test
- by hand, you can do so directly if it is a simple test:
+ with the '.tap' suffix use the TAP protocol.
- ./t/nogzip.sh
+ If you want to run a test by hand, you should be able to do so using the
+ 'test-runner' script:
- (it will be verbose by default), while if it is a TAP test you can pass
- it to your preferred TAP runner, as in e.g.:
+ ./t/ax/test-runner t/nogzip.sh
+ ./t/ax/test-runner t/add-missing.tap
- prove --verbose --merge ./t/add-missing.tap
-
- The tests can also be run directly in a VPATH build, as with:
-
- /path/to/srcdir/t/nogzip.sh
- prove --verbose --merge /path/to/srcdir/t/add-missing.tap
+ This will run the test using the correct shell, and should also work in
+ VPATH builds. Note that, to run the TAP tests this way, you'll need to
+ have the prove(1) utility available in $PATH.
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 ./t/foo.sh
- AM_TESTS_REEXEC=no prove -v -e /path/to/another/sh ./t/bar.tap
+ By default, the tests are run by a proper shell detected at configure
+ time. Here is how you can run the tests with a different shell, say
+ '/bin/my-sh':
- to run a test directly, and:
+ # Running through the makefile test driver.
+ make check AM_TEST_RUNNER_SHELL=/bin/my-sh (GNU make)
+ AM_TEST_RUNNER_SHELL=/bin/my-sh make -e check (non-GNU make)
- make check LOG_COMPILER=/path/to/sh (GNU make)
- LOG_COMPILER=/path/to/sh make -e check (non-GNU make)
+ # Run a test directly from the command line.
+ AM_TEST_RUNNER_SHELL=/bin/my-sh ./t/ax/test-runner t/foo.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. However, it is
- worth nothing that older versions of Zsh (pre-4.3) exhibited several
- bugs and incompatibilities with our uses, and are thus not supported
- for running Automake's test scripts.
+ The test scripts are written with portability in mind, and should run
+ with any decent POSIX shell. However, it is worth nothing that older
+ versions of Zsh (pre-4.3) exhibited several bugs and incompatibilities
+ with our uses, and are thus not supported for running Automake's test
+ scripts.
Reporting failures
--- /dev/null
+#!@AM_TEST_RUNNER_SHELL@
+#
+# Copyright (C) 2012 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/>.
+
+# Run an Automake test from the command line.
+# Usage:
+
+set -e; set -u
+
+: ${AM_TEST_RUNNER_SHELL='@AM_TEST_RUNNER_SHELL@'}
+: ${AM_PROVE_CMD='prove'}
+: ${AM_PROVEFLAGS='--merge --verbose'}
+: ${srcdir='@srcdir@'}
+
+error () { echo "$0: $*" >&2; exit 255; }
+
+# Some shell flags should be passed over to the test scripts.
+#while test $# -gt 0; do
+# case $1 in
+# --help) echo "Usage: $0 [SHELL-OPTIONS] TEST [TEST-OPTIONS]"; exit $?;;
+# -*)
+# esac
+#done
+
+test $# -gt 0 || error "missing argument"
+
+tst=$1; shift
+
+case $tst in
+ *.sh) wrapper () { exec "$@"; };;
+ *.tap) wrapper () { exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e "$@"; };;
+ *) error "test '$tst' has an unrecognized extension";;
+esac
+
+case $tst in
+ /*) ;;
+ *) if test -f ./$tst; then
+ tst=./$tst
+ # Support for VPATH build.
+ elif test -f $srcdir/$tst; then
+ tst=$srcdir/$tst
+ else
+ error "could not find test '$tst'"
+ fi
+ ;;
+esac
+
+wrapper "$AM_TEST_RUNNER_SHELL" "$tst" "$@"
+error "dead code reached"
t/self-check-explicit-skips.sh \
t/self-check-is_newest.tap \
t/self-check-me.tap \
-t/self-check-reexec.tap \
t/self-check-report.sh \
t/self-check-seq.tap \
t/self-check-is-blocked-signal.tap \
plan_ 5
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
keep_testdirs=; unset keep_testdirs
# This needs to be consistent with what $AM_TEST_RUNNER_SHELL
# so that false positives remain very unlikely.
set +e
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
-
# It's especially important that the 'unset' is done before sourcing
# ./defs, i.e., when 'set -e' is not active yet, for the benefit of shells
# (like Bash 2.05 and Solaris 10 /bin/ksh) that returns a non-zero status
set +e
unset am_explicit_skips stderr_fileno_
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
# FIXME: this can be simplified when we improve our runtime checks on the
# testsuite shell to ensure it supports "VAR=val shell_func" correctly.
plan_ 12
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
-
# This test becomes cumbersome if we keep the 'errexit' shell flag set.
# And removing it is no big deal, as this test is a TAP-based one, so
# that false positives remain very unlikely.
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2011-2012 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/>.
-
-# Sanity check for the automake testsuite.
-# Check that automatic re-execution of test script with the
-# configure-time $AM_TEST_RUNNER_SHELL.
-
-am_create_testdir=empty
-. ./defs || exit 1
-
-plan_ 32
-
-unset AM_TESTS_REEXEC BASH_VERSION || :
-
-cwd=$(pwd) || fatal_ "getting current working directory"
-cp "$am_top_builddir"/defs . || fatal_ "fetching 'defs' from top_builddir"
-
-#
-# Search for required bash and non-bash shells.
-#
-
-for bash_shell in \
- "$SHELL" "$AM_TEST_RUNNER_SHELL" bash bash3 bash4 :
-do
- test "$bash_shell" = : && break
- $bash_shell --version || continue
- $bash_shell -c 'test -n "$BASH_VERSION"' || continue
- break
-done
-
-# This might not be optimal, but it's much better than writing wrapper
-# scripts acting as "fake" shells.
-for non_bash_shell in \
- /bin/sh /bin/ksh sh ksh ash dash pdksh "$SHELL" "$AM_TEST_RUNNER_SHELL" :
-do
- test "$non_bash_shell" = : && break
- $non_bash_shell -c 'exit 0' || continue
- # Be sure to reject also any shell that is Zsh "in disguise" (as can
- # be found on some Debian systems, where /bin/ksh can be symlinked to
- # /bin/zsh4). This is required because our testsuite does not support
- # older versions of Zsh, and that has caused spurious failures in the
- # past.
- $non_bash_shell -c 'test -n "$ZSH_VERSION$BASH_VERSION"' && continue
- break
-done
-
-echo "bash_shell='$bash_shell'"
-echo "non_bash_shell='$non_bash_shell'"
-
-# This would denote an internal error.
-if test "$bash_shell" = : && test "$non_bash_shell" = :; then
- fatal_ "we couldn't find a bash shell nor a non-bash one"
-fi
-
-#
-# Functions used throughout the test.
-#
-
-get_ddata ()
-{
- case $1 in
- ""|*/) dsep=;;
- *) dsep=/;;
- esac
- case $1 in
- "") dname="no dir";;
- /*) dname="absolute dir";;
- *) dname="dir '$1'";;
- esac
-}
-
-get_sh ()
-{
- case $1 in
- bash) sh=$bash_shell;;
- non-bash) sh=$non_bash_shell;;
- *) fatal_ "get_sh: invalid shell type '$1'";;
- esac
-}
-
-#
-# Check how to default, force or prevent a re-execution.
-#
-
-cat > need-bash.sh <<'END'
-#!/bin/false
-. ./defs
-# Ensure that the script gets re-executed with bash. Also ensure that
-# non-standard syntax used after the inclusion of './defs' doesn't cause
-# non-bash shells to fail.
-# Subshell required to prevent some shells (e.g., Solaris 10 /bin/sh)
-# from only complaining on stderr but then exiting with exit status 0.
-(foo=abac && test xbxc = ${foo//a/x} && test -n "$BASH_VERSION")
-END
-
-sh_var=AM_TEST_RUNNER_SHELL
-sed -e "s|^am_top_builddir=.*|am_top_builddir='$cwd'|" \
- -e "s|^$sh_var=.*$|$sh_var=bash; export $sh_var|" \
- < "$am_top_builddir"/defs-static >defs-static
-
-do_reexec ()
-{
- command_ok_ "re-exec if AM_TESTS_REEXEC=$1" \
- env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.sh
-}
-
-dont_reexec ()
-{
- command_ok_ "don't re-exec if AM_TESTS_REEXEC=$1" \
- not env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.sh
-}
-
-if test "$bash_shell" = :; then
- skip_row_ 10 -r "no bash shell found" AM_TESTS_REEXEC
-elif test "$non_bash_shell" = :; then
- skip_row_ 10 -r "no non-bash shell found" AM_TESTS_REEXEC
-else
- command_ok_ "re-exec if AM_TESTS_REEXEC unset" \
- $non_bash_shell need-bash.sh
- do_reexec ''
- do_reexec yes
- do_reexec y
- do_reexec true
- do_reexec 1
- dont_reexec no
- dont_reexec n
- dont_reexec false
- dont_reexec 0
-fi
-
-#
-# Check message about the re-execution. Also check that arguments passed
-# to a test script are preserved by a re-exec, even in "corner" cases.
-#
-
-cat > dummy.sh <<'END'
-#!/bin/sh
-. ./defs
-:
-END
-
-cat > checkargs.sh <<'END'
-. ./defs
-test $# -eq 3 && test x"$1" = x'a' && test x"$2" = x && test x"$3" = x"-e"
-END
-
-chmod a+x dummy.sh checkargs.sh
-
-mkdir sub
-cp dummy.sh checkargs.sh defs sub
-sed -e "s|^am_top_builddir=.*|am_top_builddir='$cwd'|" \
- < "$am_top_builddir"/defs-static > defs-static
-sed -e "s|^am_top_builddir=.*|am_top_builddir='$cwd/sub'|" \
- < "$am_top_builddir"/defs-static > sub/defs-static
-
-check_preserve_args ()
-{
- dir=$1; shift
- get_ddata "$dir"
- $sh "${dir}${dsep}checkargs.sh" a '' -e && r='ok' || r='not ok'
- result_ "$r" "$sh re-exec preserving args [$dname]"
-}
-
-check_reexec_message ()
-{
- dir=$1; shift
- get_ddata "$dir"
- $sh "${dir}${dsep}dummy.sh" "$@" \
- | grep "^exec $AM_TEST_RUNNER_SHELL ${dir}${dsep}dummy\\.sh $*\$" \
- && r='ok' || r='not ok'
- result_ "$r" "$sh display re-exec message [$dname] [args: $*]"
-}
-
-./dummy.sh a b \
- | grep "^exec $AM_TEST_RUNNER_SHELL \\./dummy\\.sh a b$" \
- && r='ok' || r='not ok'
-result_ "$r" "direct run display re-exec message [args: a b]"
-
-./checkargs.sh a '' -e && r='ok' || r='not ok'
-result_ "$r" "direct re-exec preserving args"
-
-for sh_type in non-bash bash; do
- get_sh $sh_type
- if test "$sh" = :; then
- skip_row_ 5 -r "no $sh_type shell available" "re-exec message"
- skip_row_ 5 -r "no $sh_type shell available" "re-exec preserving args"
- continue
- fi
- check_preserve_args ''
- check_reexec_message '' a b c
- check_preserve_args .
- check_reexec_message . a b c
- cd sub
- check_preserve_args ..
- check_reexec_message .. a b c
- cd ..
- check_preserve_args "$cwd"
- check_reexec_message "$cwd" a -b c-
- check_preserve_args sub
- check_reexec_message sub 1 2 3 4
-done
-
-: