1 #!@AM_TEST_RUNNER_SHELL@
4 # Copyright (C) 2012-2024 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'.
56 am_test_prefer_config_shell \
57 am_original_AUTOMAKE \
62 eval "$v= && unset $v" || exit 1
66 xecho () { printf '%s\n' "$*"; }
67 error () { echo "$0: $*" >&2; exit 255; }
69 # Some shell flags should be passed over to the test scripts.
71 while test $# -gt 0; do
74 xecho "Usage: $0 [--shell=PATH] [-k] [SHELL-OPTIONS]" \
75 "[VAR=VALUE ...] TEST [TEST-OPTIONS]"
79 test $# -gt 1 || error "missing argument for option '$1'"
80 AM_TEST_RUNNER_SHELL=$2
84 AM_TEST_RUNNER_SHELL=${1#--shell=}
87 test $# -gt 1 || error "missing argument for option '$1'"
88 shell_opts="$shell_opts -o $2"
91 -k|--keep-testdir|--keep-testdirs)
92 keep_testdirs=yes; export keep_testdirs;;
94 # Assume it is an option to pass through to the shell.
95 shell_opts="$shell_opts $1";;
97 var=${1%%=*} val=${1#*=}
98 xecho "$var" | LC_ALL=C grep '^[a-zA-Z_][a-zA-Z0-9_]*$' >/dev/null \
99 || error "'$var': invalid variable name"
100 eval "$var=\$val && export $var" || exit 1
108 test $# -gt 0 || error "missing argument"
114 *) if test -f ./$tst; then
116 # Support for VPATH build.
117 elif test -f $srcdir/$tst; then
120 error "could not find test '$tst'"
127 exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" ${1+"$@"} ;;
129 exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e \
130 "$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" ${1+"$@"} ;;
132 error "test '$tst' has an unrecognized extension" ;;
135 error "dead code reached"