1 #!@AM_TEST_RUNNER_SHELL@
4 # Copyright (C) 2012-2017 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # Run an Automake test from the command line.
23 : ${AM_TEST_RUNNER_SHELL='@AM_TEST_RUNNER_SHELL@'}
24 : ${AM_PROVE_CMD='prove'}
25 : ${AM_PROVEFLAGS='--merge --verbose'}
26 : ${srcdir='@srcdir@'}
27 : ${abs_srcdir='@abs_srcdir@'}
28 : ${abs_builddir='@abs_builddir@'}
29 : ${PATH_SEPARATOR='@PATH_SEPARATOR@'}
31 # For sourcing of extra "shell libraries" by our test scripts. As per
32 # POSIX, sourcing a file with '.' will cause it to be looked up in $PATH
33 # in case it is given with a relative name containing no slashes.
34 if test "$srcdir" != .; then
35 PATH=$abs_srcdir/t/ax$PATH_SEPARATOR$PATH
37 PATH=$abs_builddir/t/ax$PATH_SEPARATOR$PATH
40 # For use by the testsuite framework. The Automake test harness
41 # define this, so we better do the same.
44 # Some testsuite-influential variables should be overridable from the
45 # test scripts, but not from the environment.
46 # Keep this in sync with the 'Makefile.am:AM_TESTS_ENVIRONMENT'.
51 am_test_prefer_config_shell \
52 am_original_AUTOMAKE \
57 eval "$v= && unset $v" || exit 1
61 xecho () { printf '%s\n' "$*"; }
62 error () { echo "$0: $*" >&2; exit 255; }
64 # Some shell flags should be passed over to the test scripts.
66 while test $# -gt 0; do
69 xecho "Usage: $0 [--shell=PATH] [-k] [SHELL-OPTIONS]" \
70 "[VAR=VALUE ...] TEST [TEST-OPTIONS]"
74 test $# -gt 1 || error "missing argument for option '$1'"
75 AM_TEST_RUNNER_SHELL=$2
79 AM_TEST_RUNNER_SHELL=${1#--shell=}
82 test $# -gt 1 || error "missing argument for option '$1'"
83 shell_opts="$shell_opts -o $2"
86 -k|--keep-testdir|--keep-testdirs)
87 keep_testdirs=yes; export keep_testdirs;;
89 # Assume it is an option to pass through to the shell.
90 shell_opts="$shell_opts $1";;
92 var=${1%%=*} val=${1#*=}
93 xecho "$var" | LC_ALL=C grep '^[a-zA-Z_][a-zA-Z0-9_]*$' >/dev/null \
94 || error "'$var': invalid variable name"
95 eval "$var=\$val && export $var" || exit 1
103 test $# -gt 0 || error "missing argument"
109 *) if test -f ./$tst; then
111 # Support for VPATH build.
112 elif test -f $srcdir/$tst; then
115 error "could not find test '$tst'"
122 exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" ${1+"$@"} ;;
124 exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e \
125 "$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" ${1+"$@"} ;;
127 error "test '$tst' has an unrecognized extension" ;;
130 error "dead code reached"