2010-12-22 Stefano Lattarini <stefano.lattarini@gmail.com>
+ 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 <stefano.lattarini@gmail.com>
+
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.
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
. ./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$//'`
## ---------------------------------------- ##
# 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
# 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