[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(maybe) zsh-related bug in tests/defs.in
From: |
Stefano Lattarini |
Subject: |
(maybe) zsh-related bug in tests/defs.in |
Date: |
Sun, 23 Aug 2009 22:46:47 +0200 |
User-agent: |
KMail/1.11.4 (Linux/2.6.26-1-686; KDE/4.2.4; i686; ; ) |
Hi everybody.
I found what follows using the latest automake from the git
repository, on my debian unstable system.
While trying to run the automake testsuite *in parallel*, using
zsh (version 4.3), I ran into some apparently random failures
(with most test scripts failing), which I tracked down to the
way $testSubDir is defined in `tests/defs.in'.
In fact, in `tests/defs.in' there are the following definitions:
me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
testSubDir=$me.dir
Thus one would expect that, if `test.foo' does the customary:
./defs || Exit 1
then it ends up defining `$me' to `foo' and $testSubDir to `foo.dir'.
Unfortunately, this is not the case with zsh.
By default, in a sourced script, zsh set $0 to the path of that
same sourced script -- more info at:
http://zsh.dotsrc.org/Doc/Release/Parameters.html#IDX166
This problem *seems* to be taken care of in `defs.in' itself, by the
command `emulate sh', but unfortunately this command is issued
too late.
In fact, when `foo.test' includes `./defs', it isn't in "emulate sh"
mode yet, so that in `./defs' tha value of $0 remains set to
`./defs', no matter if the sh-compatibility mode is later
activated. Thus $me is *always* set to `defs' and $testSubDir
is *always* set to `defs.dir'. D'oh.
Some commands showing this problem in action:
$ git clone git://git.savannah.gnu.org/automake.git
$ cd automake
$ ./bootstrap && ./configure
$ cd tests
$ cat >foo.test <<'EOF'
. ./defs || exit 100
test x"$me" = x"foo" || Exit 1
Exit 0
EOF
$ bash foo.test
=== Running test foo.test
++ pwd
/tmp/automake/tests/foo.dir
+ test xfoo = xfoo
+ Exit 0
...
: exit 0
+ exit 0
$ dash foo.test
=== Running test foo.test
+ pwd
/tmp/automake/tests/foo.dir
+ test xfoo = xfoo
+ Exit 0
...
: exit 0
+ exit 0
$ zsh foo.test
=== Running test ./defs
+./defs:427> pwd
/tmp/automake/tests/defs.dir
+foo.test:2> test xdefs '=' xfoo
+foo.test:2> Exit 1
+Exit:2> set +e
+Exit:3> exit 1
+Exit:4> exit 1
+foo.test:2> exit_status=1
+foo.test:2> set +e
+foo.test:2> cd /tmp/automake/tests
+foo.test:2> case 1, (0,)
+foo.test:2> test 0 '!=' 0
+foo.test:2> echo ': exit 1'
: exit 1
+foo.test:2> exit 1
- - -
I'm not sure if this can be truly classified as a bug, since the
test scripts all have a `#!/bin/sh' shebang line, and I hope
that few people or systems are crazy enough to use zsh as
their default Bourne shell. Anyway, this problem might deserve
some consideration.
Regards,
Stefano
- (maybe) zsh-related bug in tests/defs.in,
Stefano Lattarini <=