automake-patches
[Top][All Lists]
Advanced

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

Fix parallel testsuite run with zsh


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

Hello automakers.

I'll soon push a patch which works around a Zsh incompatibility in
the handling of `$0'; this incompatibility currently prevents a
successful run of the automake testsuite in parallel with Zsh as
$(TEST_LOG_COMPILER).

Here is an in-depth description and analysis of the problem.
I'm posting it in advance so that it will be possible to refer to
it from the ChangeLog entry of the patch (thus avoiding excessive
verbosity there).

And JFTR, here is the original bug report & analysis:
  <http://lists.gnu.org/archive/html/bug-automake/2009-08/msg00013.html>
and here is and older patch:
  <http://lists.gnu.org/archive/html/automake-patches/2010-01/msg00017.html>

-*-*-*-
    
The automake testcases are run each in its own temporary directory,
whose name is computed (by code in `tests/defs') from the name of the
testcase itself.  For example, the test `foo.test' is expected to be
executed in a temporary directory named `foo.dir'.  The computing of
the test name is done using the `$0' special shell variable.

Unfortunately, an incompatibility in the way Zsh handles the `$0'
variable in sourced scripts might cause serious problems with this
scheme.

By default, if Zsh is not running in Bourne compatibility mode, then
in any script sourced with the `.' builtin it sets `$0' to the path
of *that same sourced script*; more information about this behaviour
can be found at:
  <http://zsh.sourceforge.net/Doc/Release/Parameters.html>

Here is a simple demonstration:

  $ cat > foo.sh <<'END'
  echo 1. $0
  . ./bar.sh
  END
  $ cat > bar.sh <<'END'
  echo 2. $0
  END
  $ sh foo.sh
  1. foo.sh
  2. foo.sh
  $ zsh foo.sh
  1. foo.sh
  2. ./bar.sh

Now, at a first glance, it seems that `tests/defs' (well, technically
`tests/defs-static', but these details don't matter here) already takes
care of the incompatibility, since it puts Zsh into Bourne compatibility
mode with the command `emulate sh'.  Unfortunately, such a command is
issued too late to really work as expected.

In fact, when a test, say `foo.test', includes `./defs', it isn't in
Bourne compatibility mode yet, so that, when the execution of the code
in `./defs' begins, the value of `$0' gets set to "./defs"; activating
Bourne compatibility mode later (in either `defs' or `defs-static')
cannot prevent or change this.  Thus the `$me' variable is always set
to "defs", and the temporary testcase directory is *always* set to
"defs.dir".

And here comes the problem.

Apart from making debugging more difficult (since the temporary
directories left behind by failed testcases are happily overridden
by following, unrelated testcases), the issue above will also cause
the testsuite to *utterly break* when run in parallel mode, since
in that case many tests will use the *same* temporary directory
*simultaneously*, and thus will stomp on each other feet.

-*-*-*-
    
The change I'm going to apply will work around the problems described
above for modern-enough Zsh version, and will offer better error
messages (instead of potential random failures) for older versions.

Regards,
   Stefano



reply via email to

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