We once used that feature in our wrapper tests; but now (and probably
even since commit '
v1.11-1308-g375f23d' of 2011-09-08, "testsuite:
revamp generation of autogenerated tests") it is not needed anymore.
By removing it we can simplify our growingly complex testsuite framework
a little.
* t/ax/test-inist.sh ($me): Do not initialize it here (and only if not
already set), instead ...
* defs-static.in ($me): ... initialize it here unconditionally.
Do not check anymore that $me doesn't come from the environment: that
wouldn't cause any problem now.
Now that '$me' is defined early, prefer it over 'argv0' in early error
messages, both here ...
* defs: ... and here.
* Makefile.am (AM_TESTS_ENVIRONMENT): Do not bother "nullifying" $me
anymore.
* t/self-check-env-sanitize.tap: Adjust.
* t/self-check-me.tap: Likewise.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
# test scripts, but not from the environment.
AM_TESTS_ENVIRONMENT = \
for v in \
- me \
required \
am_using_tap \
am_serial_tests \
*)
# Ensure we can find ourselves.
if test ! -f "$argv0"; then
- echo "$argv0: unable to find myself" >&2
+ echo "$me: unable to find myself: '$argv0'" >&2
exit 99
fi
AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
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 "$argv0: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
+ echo "$me: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
exit 99
;;
esac
case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac
fi
+# The name of the current test (without the '.sh' or '.tap' suffix).
+me=${argv0##*/} # Strip all directory components.
+case $me in # Strip test suffix.
+ *.tap) me=${me%.tap};;
+ *.sh) me=${me%.sh} ;;
+ esac
+
# Check that the environment is properly sanitized.
# Having variables exported to the empty string is OK, since our code
# treats such variables as if they were unset.
for var in \
- me \
required \
am_using_tap \
am_serial_tests \
am_original_ACLOCAL \
; do
if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then
- echo "$argv0: variable '$var' is set in the environment:" \
+ echo "$me: variable '$var' is set in the environment:" \
"this is unsafe" >&2
exit 99
fi
am_system_acdir=$am_top_srcdir/m4/acdir
;;
*)
- echo "$argv0: variable 'am_running_installcheck' has invalid"
+ echo "$me: variable 'am_running_installcheck' has invalid"
"value '$am_running_installcheck'" >&2
exit 99
;;
# Enable the errexit shell flag early.
set -e
-# The name of the current test (without the '.sh' or '.tap' suffix).
-# Test scripts can override it if they need to (but this should
-# be done carefully).
-if test -z "$me"; then
- # Strip all directory components.
- me=${argv0##*/}
- # Strip test suffix.
- case $me in
- *.tap) me=${me%.tap};;
- *.sh) me=${me%.sh} ;;
- esac
-fi
-
## --------------------- ##
## Early sanity checks. ##
set -x
exec 5>&1
-plan_ 18 # Two times the number of variable names in $vars.
+plan_ 16 # Two times the number of variable names in $vars.
vars='
- me
required
am_serial_tests
am_using_tap
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Sanity check for the automake testsuite.
-# Make sure that $me gets automatically defined by './defs', and that it
-# can be overridden by the test script.
+# Make sure that $me gets automatically defined by './defs'.
am_create_testdir=no
. ./defs || exit 1
-plan_ 14
+plan_ 12
AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
do_check foo.bar 'foo\.bar'
do_check abc. 'abc\.'
-# If we override $me, ./defs should not modify it.
+# A definition of $me in the environment should be ignored.
-s=$($AM_TEST_RUNNER_SHELL -c 'me=foo.sh && . ./defs && echo me=$me' bad.sh)
+s=$(me=bad $AM_TEST_RUNNER_SHELL -c '. ./defs && echo me=$me' foo.sh)
command_ok_ "override of \$me before ./defs causes no error" \
test $? -eq 0
r='ok'
-printf '%s\n' "$s" | grep '^me=foo\.sh$' || r='not ok'
-printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
-result_ "$r" "override of \$me before ./defs is honored"
-unset r
-
-# Overriding $me after sourcing ./defs-static should work.
-s=$($AM_TEST_RUNNER_SHELL -c '. ./defs-static && me=zardoz &&
- . ./defs && echo me=$me' bad.sh)
-command_ok_ "override of \$me after ./defs-static causes no error" \
- test $? -eq 0
-
-r='ok'
-printf '%s\n' "$s" | grep '^me=zardoz$' || r='not ok'
-printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
-result_ "$r" "override of \$me after ./defs-static is honored"
+printf '%s\n' "$s" | grep '^me=foo$' || r='not ok'
+printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
+result_ "$r" "\$me from the environment is ignored"
unset r
: