automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix parallel testsuite run with zsh


From: Stefano Lattarini
Subject: Re: Fix parallel testsuite run with zsh
Date: Wed, 22 Dec 2010 18:12:12 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Here it is the promised patch.

Tested with:
 - Zsh 3.0.8 (total failure with clear, explicative messages, as expected)
 - Zsh 4.2 (total failure with clear, explicative messages, as expected)
 - Zsh 4.3.10 (no regression, and `-o no_function_argzero' no more needed)
 - Dash 0.5.2 (success)
 - Solaris /bin/sh (success)

Pushed to tests-init.

Regards,
   Stefano
From 7cd2094693437d3d7fbdb69d577758fe1d6e0900 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Sat, 30 Jan 2010 14:01:39 +0100
Subject: [PATCH] Fix parallel testsuite run with Zsh.

This change deals with a Zsh incompatibility in the handling
of the special shell variable `$0' in sourced files; this
incompatibility used to cause utter breakage when the
Automake testsuite was run in parallel mode with Zsh as
the $(TEST_LOG_COMPILER).

For more information, please refer to the thread "Fix parallel
testsuite run with zsh" on automake-patches, dated 2010-12-22:
 <http://lists.gnu.org/archive/html/automake-patches/2010-12/msg00135.html>

This change works around the problems described above for Zsh 4.3
or later, and offers better error messages (instead of random
failures) for earlier Zsh version.

* tests/README (Supported shells): When describing the manual
workaround about the Zsh incompatibility in the handling of `$0',
tell that it is now needed only with Zsh versions preceding 4.3.
Done also some minor rewordings.
* tests/defs-static.in ($argv0): New variable, offers a workaround
for the Zsh incompatibility in the handling of `$0'.
Abort if that variable cannot be correctly set (can happen only
in older Zsh version).
* tests/defs ($me): Define using `$argv0', not `$0'.
---
 ChangeLog            |   24 ++++++++++++++++++++++++
 tests/README         |   20 +++++++++++---------
 tests/defs           |    2 +-
 tests/defs-static.in |   28 +++++++++++++++++++++++++++-
 4 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 378742e..2ea4caa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2010-12-22  Stefano Lattarini  <address@hidden>
 
+       Fix parallel testsuite run with Zsh.
+       This change deals with a Zsh incompatibility in the handling
+       of the special shell variable `$0' in sourced files; this
+       incompatibility used to cause utter breakage when the
+       Automake testsuite was run in parallel mode with Zsh as
+       the $(TEST_LOG_COMPILER).
+       For more information, please refer to the thread "Fix parallel
+       testsuite run with zsh" on automake-patches, dated 2010-12-22:
+        
<http://lists.gnu.org/archive/html/automake-patches/2010-12/msg00135.html>
+       This change works around the problems described above for Zsh 4.3
+       or later, and offers better error messages (instead of random
+       failures) for earlier Zsh version.
+       * tests/README (Supported shells): When describing the manual
+       workaround about the Zsh incompatibility in the handling of `$0',
+       tell that it is now needed only with Zsh versions preceding 4.3.
+       Done also some minor rewordings.
+       * tests/defs-static.in ($argv0): New variable, offers a workaround
+       for the Zsh incompatibility in the handling of `$0'.
+       Abort if that variable cannot be correctly set (can happen only
+       in older Zsh version).
+       * tests/defs ($me): Define using `$argv0', not `$0'.
+
+2010-12-22  Stefano Lattarini  <address@hidden>
+
        Tests defs: keep track of original $AUTOMAKE and $ACLOCAL values.
        This is especially useful for tests which might want to run
        automake and aclocal without additional flags and warnings.
diff --git a/tests/README b/tests/README
index 88da783..1369bd3 100644
--- a/tests/README
+++ b/tests/README
@@ -70,17 +70,19 @@ Supported shells
   should run with any decent Bourne-compatible shell.
 
   However, some care must be used with Zsh, since, when not directly
-  starting in Bourne-compatibility mode, it has some incompatibilities
-  in the handling of `$0' which conflict with our usage, and which have
-  no easy workaround.  Thus, if you want to run a test script, say
-  foo.test, with Zsh, you *can't* simply do `zsh foo.test', but you
-  *must* resort to:
+  started in Bourne-compatibility mode, it has some incompatibilities
+  in the handling of `$0' which conflict with our usage.  Our testsuite
+  can automatically work around these incompatibilities when a version
+  4.3 or later of Zsh is used, but unfortunately not when an older
+  version of Zsh is used.  Thus, if you want to run a test script, say
+  foo.test, with Zsh 4.2, you *can't* simply do `zsh foo.test', but
+  you *must* resort to:
     zsh -o no_function_argzero foo.test
 
-  Note that this problem does not occur if zsh is executed through a
-  symlink with a basename of `sh', since in that case it starts
-  in Bourne compatibility mode.  So you should be perfectly safe when
-  /bin/sh is zsh.
+  Note that this problem does not occur if Zsh is executed through
+  a symlink with a basename of `sh', since in that case Zsh starts
+  in Bourne compatibility mode.  So you should be perfectly safe
+  when /bin/sh is Zsh, even a it's version < 4.3.
 
 
 Reporting failures
diff --git a/tests/defs b/tests/defs
index 134dc78..f04a756 100644
--- a/tests/defs
+++ b/tests/defs
@@ -30,7 +30,7 @@ test -f ./defs-static || {
 . ./defs-static || exit 99
 
 # The name of the current test (without the `.test' suffix.)
-me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'`
 
 
 ## ---------------------------------------- ##
diff --git a/tests/defs-static.in b/tests/defs-static.in
index c4ae758..9143178 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -21,7 +21,7 @@
 # IMPORTANT: Multiple inclusions of this file should be idempotent!
 
 # Be more Bourne compatible.
-# (Snippet copied from configure's initialization in Autoconf 2.64)
+# (Snippet inspired to configure's initialization in Autoconf 2.64)
 DUALCASE=1; export DUALCASE # for MKS sh
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
@@ -30,7 +30,33 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 
2>&1; then
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
+  # If Zsh is not started directly in Bourne-compatibility mode, it has
+  # some incompatibilities in the handling of `$0' that conflict with
+  # our usage: i.e., `$0' inside a file sourced with the `.' builtin is
+  # temporarily set to the name of the sourced file.
+  # Work around this when possible, otherwise abort the script.
+  # Note that a bug in some versions of Zsh prevents us from resetting $0
+  # in a sourced script, so the use of $argv0.  For more info see:
+  #  <http://www.zsh.org/mla/workers/2009/msg01140.html>
+  # Note: the apparently useless 'eval' below are needed by at least
+  # dash 0.5.2, to prevent it from bailing out with an error like
+  # "Syntax error: Bad substitution"
+  if eval '[[ "$0" = *."test" ]]'; then
+    # Good, FUNCTION_ARGZERO option was already off when this file was
+    # sourced.  Thus we've nothing to do.
+    argv0=$0
+  elif eval 'test -n "${functrace[-1]}"'; then
+    # FUNCTION_ARGZERO option was on, but we have a easy workaround.
+    eval 'argv0=${functrace[-1]%:*}'
+  else
+    # Give up.
+    echo "$0: cannot determine the path of running test script" >&2
+    echo "$0: test was running with Zsh version $ZSH_VERSION" >&2
+    echo "$0: did you enable the NO_FUNCTION_ARGZERO option?" >&2
+    exit 99
+  fi
 else
+  argv0=$0
   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
 
-- 
1.7.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]