Hash :
cd995fe6
Author :
Date :
2022-01-24T01:02:41
tests: clear autotools env vars Fixes automake bug https://bugs.gnu.org/16714. The testsuite will try and retain these env vars when recursively running itself, but doesn't distinguish between vars coming from the env where the tests were launched. This breaks if the user happens to `export ACLOCAL=alocal` before `make check`. This gets a little more confusing in that the Makefile appears to export these already: ACLOCAL = ".../automake/pre-inst-env" aclocal-1.16 In reality, while those are set in the make execution environment, they aren't exported into the process environment, so children (i.e. shell processes in make rules) don't have them set. That's why tests work for most people today. However, if the user has first exported "ACLOCAL" in the parent make environment (regardless of value), then make's value will reset the process environment, and then that will leak into the children. That's why we see errors that look like the makefile env vars are leaking for these people. At any rate, the fix is to update the test harness to clear these vars that the test suite relies upon, especially the ones that are also set in the Makefiles. That includes AUTOUPDATE even though it currently isn't used inside any of the tests. * t/local.mk: Add ACLOCAL, AUTOCONF, AUTOHEADER, AUTOMAKE, and AUTOUPDATE to the env unset list. * t/ax/runtest.in: Likewise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
#!@AM_TEST_RUNNER_SHELL@
# @configure_input@
#
# Copyright (C) 2012-2022 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 <https://www.gnu.org/licenses/>.
# Run an Automake test from the command line.
set -e; set -u
: ${AM_TEST_RUNNER_SHELL='@AM_TEST_RUNNER_SHELL@'}
: ${AM_PROVE_CMD='prove'}
: ${AM_PROVEFLAGS='--merge --verbose'}
: ${srcdir='@srcdir@'}
: ${abs_srcdir='@abs_srcdir@'}
: ${abs_builddir='@abs_builddir@'}
: ${PATH_SEPARATOR='@PATH_SEPARATOR@'}
# For sourcing of extra "shell libraries" by our test scripts. As per
# POSIX, sourcing a file with '.' will cause it to be looked up in $PATH
# in case it is given with a relative name containing no slashes.
if test "$srcdir" != .; then
PATH=$abs_srcdir/t/ax$PATH_SEPARATOR$PATH
fi
PATH=$abs_builddir/t/ax$PATH_SEPARATOR$PATH
export PATH
# For use by the testsuite framework. The Automake test harness
# define this, so we better do the same.
export srcdir
# Some testsuite-influential variables should be overridable from the
# test scripts, but not from the environment.
# Keep this in sync with the 'Makefile.am:AM_TESTS_ENVIRONMENT'.
for v in \
ACLOCAL \
AUTOCONF \
AUTOHEADER \
AUTOMAKE \
AUTOUPDATE \
required \
am_test_protocol \
am_serial_tests \
am_test_prefer_config_shell \
am_original_AUTOMAKE \
am_original_ACLOCAL \
am_test_lib_sourced \
test_lib_sourced \
; do
eval "$v= && unset $v" || exit 1
done
unset v
xecho () { printf '%s\n' "$*"; }
error () { echo "$0: $*" >&2; exit 255; }
# Some shell flags should be passed over to the test scripts.
shell_opts=
while test $# -gt 0; do
case $1 in
--help)
xecho "Usage: $0 [--shell=PATH] [-k] [SHELL-OPTIONS]" \
"[VAR=VALUE ...] TEST [TEST-OPTIONS]"
exit $?
;;
--shell)
test $# -gt 1 || error "missing argument for option '$1'"
AM_TEST_RUNNER_SHELL=$2
shift
;;
--shell=*)
AM_TEST_RUNNER_SHELL=${1#--shell=}
;;
-o)
test $# -gt 1 || error "missing argument for option '$1'"
shell_opts="$shell_opts -o $2"
shift
;;
-k|--keep-testdir|--keep-testdirs)
keep_testdirs=yes; export keep_testdirs;;
-*)
# Assume it is an option to pass through to the shell.
shell_opts="$shell_opts $1";;
*=*)
var=${1%%=*} val=${1#*=}
xecho "$var" | LC_ALL=C grep '^[a-zA-Z_][a-zA-Z0-9_]*$' >/dev/null \
|| error "'$var': invalid variable name"
eval "$var=\$val && export $var" || exit 1
;;
*)
break;;
esac
shift
done
test $# -gt 0 || error "missing argument"
tst=$1; shift
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
case $tst in
*.sh)
exec $AM_TEST_RUNNER_SHELL $shell_opts "$tst" ${1+"$@"} ;;
*.tap)
exec "$AM_PROVE_CMD" $AM_PROVEFLAGS -e \
"$AM_TEST_RUNNER_SHELL $shell_opts" "$tst" ${1+"$@"} ;;
*)
error "test '$tst' has an unrecognized extension" ;;
esac
error "dead code reached"