]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests init: don't bother allowing '$me' to be overridable
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 28 Jun 2012 16:21:33 +0000 (18:21 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 28 Jun 2012 16:35:44 +0000 (18:35 +0200)
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>
Makefile.am
defs
defs-static.in
t/ax/test-init.sh
t/self-check-env-sanitize.tap
t/self-check-me.tap

index 76f1cb345189e1250fb74957cce946d16f94de72..9d581551428e43bedf24b53c06f88c4f4deb1598 100644 (file)
@@ -336,7 +336,6 @@ TESTS = ## Will be updated later.
 # test scripts, but not from the environment.
 AM_TESTS_ENVIRONMENT = \
   for v in \
-    me \
     required \
     am_using_tap \
     am_serial_tests \
diff --git a/defs b/defs
index 217665eaf4de012ec91c760b3de2a3338046a986..143be663ac06870272cb56702a6b845bb921572c 100644 (file)
--- a/defs
+++ b/defs
@@ -33,7 +33,7 @@ case ${AM_TESTS_REEXEC-yes} in
   *)
     # 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
@@ -49,7 +49,7 @@ case ${AM_TESTS_REEXEC-yes} in
     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
index da5dcffdef6c1fe9136f444840c277f6939a3b18..781571ce0bd39e5457598f0e874334351919eae0 100644 (file)
@@ -53,11 +53,17 @@ else
   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 \
@@ -68,7 +74,7 @@ for var in \
   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
@@ -113,7 +119,7 @@ case ${am_running_installcheck:=no} in
     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
     ;;
index 83fe6eb86713cbc67e20a2da7e80b285271792d1..d0b4cd7fc1de6515f40d89ada145703286f85ee2 100644 (file)
 # 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. ##
index 4169998a2485f23d01f37b1e849700ff0a9411a3..3e48d895fe708646d7f64defa4b2347a9c2049f5 100755 (executable)
@@ -24,10 +24,9 @@ am_create_testdir=no
 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
index bd75fa9b3c764e726b478804556068b97007eb83..717fe2e37bbe69464f42733a48f63b6a1735f033 100755 (executable)
 # 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
 
@@ -46,28 +45,16 @@ done
 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
 
 :