tests: fix automatic re-execution of tests with Zsh
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 23 Jun 2012 11:42:10 +0000 (13:42 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 23 Jun 2012 11:54:10 +0000 (13:54 +0200)
* defs: Use '$argv0' instead of '$0'.  With Zsh not started right
away in Bourne-compatibility mode, the latter will be the path not
of the test script itself, but of the file it's currently sourcing
-- i.e., in our case, './defs'.  This would cause the automatic
re-execution code to execute './defs' (basically a no-op) rather
than re-run the test correctly.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
defs

diff --git a/defs b/defs
index a47a541..217665e 100644 (file)
--- a/defs
+++ b/defs
@@ -32,8 +32,8 @@ case ${AM_TESTS_REEXEC-yes} in
     ;;
   *)
     # Ensure we can find ourselves.
-    if test ! -f "$0"; then
-      echo "$0: unable to find myself" >&2
+    if test ! -f "$argv0"; then
+      echo "$argv0: unable to find myself" >&2
       exit 99
     fi
     AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
@@ -46,10 +46,10 @@ case ${AM_TESTS_REEXEC-yes} in
       *x*) opts=-x;;
       *) opts=;;
     esac
-    echo exec $AM_TEST_RUNNER_SHELL $opts "$0" "$*"
-    exec $AM_TEST_RUNNER_SHELL $opts "$0" ${1+"$@"}
+    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 "$0: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
+    echo "$argv0: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2
     exit 99
     ;;
 esac