From 486f8b31f351795612847e270d44a254e07bf318 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini
Date: Wed, 9 Sep 2009 21:49:03 +0200
Subject: [PATCH] Fix testsuite: avoid Zsh-related problems
* tests/README: Describe a bug (or at least a weird behaviour) in
the way the 4.x versions of Zsh deal with the `-x' a.k.a. `xtrace'
switch. This bug can unexpectedly break apparently flawless test
scripts. Describe also a workaround for it, involving the use of
the new shell function `run_CMD()', defined in tests/defs.in (see
below).
* tests/defs.in: New subroutine `run_CMD()'. Implementation of
subroutine `AUTOMAKE_run()' rewritten to use `run_CMD()'. Unset
variable `TEST_LOG_COMPILER', that might cause spurious failures
by leaking in the environment of the make processes executed by the
test scripts. Updated the code which ensures Bourne-compatibility
in Zsh, by adding a call to `setopt NO_GLOB_SUBST' (as done by
autoconf 2.64).
* tests/acloca14.test:
* tests/acloca17.test:
* tests/acloca18.test:
* tests/aclocal.test:
* tests/aclocal3.test:
* tests/aclocal8.test:
* tests/acsilent.test:
* tests/alpha.test:
* tests/ammissing.test:
* tests/ansi3.test:
* tests/ansi3b.test:
* tests/check8.test:
* tests/cond39.test:
* tests/defs.in:
* tests/depcomp2.test:
* tests/depcomp4.test:
* tests/depend5.test:
* tests/depend6.test:
* tests/discover.test:
* tests/distcom3.test:
* tests/fn99.test:
* tests/fn99subdir.test:
* tests/gnits2.test:
* tests/gnits3.test:
* tests/help.test:
* tests/init.test:
* tests/instsh.test:
* tests/ldadd.test:
* tests/libtool7.test:
* tests/libtool9.test:
* tests/lisp3.test:
* tests/ltorder.test:
* tests/man4.test:
* tests/mdate.test:
* tests/missing3.test:
* tests/missing4.test:
* tests/missing6.test:
* tests/obsolete.test:
* tests/output-order.test:
* tests/pr220.test:
* tests/pr300-ltlib.test:
* tests/python11.test:
* tests/python4.test:
* tests/python5.test:
* tests/python6.test:
* tests/python7.test:
* tests/python8.test:
* tests/python9.test:
* tests/sanity.test:
* tests/subobj.test:
* tests/subobj9.test:
* tests/unused.test:
* tests/vars3.test:
* tests/version8.test:
use new subroutine `run_CMD()' instead of hand-crafted stdout and/or
stderr redirections; this, togheter with the changes in file
`tests/defs.in', fixes misbehaviour w.r.t. zsh for (at least) the
following tests:
- aclocal8.test
- acsilent.test
- depcomp2.test
- getopt.test
- location.test
- missing3.test
- output-order.test
- parallel-tests3.test
- parallel-tests4.test
- unused.test
- warnopts.test
- check9-p.test
---
ChangeLog | 88 ++++++++++++++++++++++++++++++++++++++
tests/README | 23 ++++++++++
tests/acloca14.test | 2 +-
tests/acloca17.test | 4 +-
tests/acloca18.test | 8 +--
tests/aclocal.test | 6 +-
tests/aclocal3.test | 3 +-
tests/aclocal8.test | 5 +-
tests/acsilent.test | 5 +-
tests/alpha.test | 3 +-
tests/ammissing.test | 3 +-
tests/ansi3.test | 3 +-
tests/ansi3b.test | 3 +-
tests/check8.test | 8 +---
tests/cond39.test | 6 +--
tests/defs.in | 107 ++++++++++++++++++++++++++++++++++++++++-------
tests/depcomp2.test | 7 ++-
tests/depcomp4.test | 5 +-
tests/depend5.test | 5 +--
tests/depend6.test | 7 +--
tests/discover.test | 3 +-
tests/distcom3.test | 5 +-
tests/fn99.test | 3 +-
tests/fn99subdir.test | 3 +-
tests/gnits2.test | 4 +-
tests/gnits3.test | 4 +-
tests/help.test | 2 +-
tests/init.test | 8 +++-
tests/instsh.test | 5 +-
tests/ldadd.test | 3 +-
tests/libtool7.test | 21 ++++-----
tests/libtool9.test | 7 ++-
tests/lisp3.test | 5 +-
tests/ltorder.test | 3 +-
tests/man4.test | 6 +--
tests/mdate.test | 3 +-
tests/missing3.test | 16 ++++----
tests/missing4.test | 6 +--
tests/missing6.test | 5 +-
tests/obsolete.test | 4 +-
tests/output-order.test | 9 ++--
tests/pr220.test | 3 +-
tests/pr300-ltlib.test | 6 +--
tests/python11.test | 4 +-
tests/python4.test | 3 +-
tests/python5.test | 3 +-
tests/python6.test | 3 +-
tests/python7.test | 3 +-
tests/python8.test | 3 +-
tests/python9.test | 3 +-
tests/sanity.test | 6 +--
tests/subobj.test | 3 +-
tests/subobj9.test | 4 +-
tests/unused.test | 4 +-
tests/vars3.test | 3 +-
tests/version8.test | 3 +-
56 files changed, 312 insertions(+), 168 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 152e0c6..0df5ec3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,91 @@
+2009-09-09 Stefano Lattarini
+
+ Fix testsuite: avoid Zsh-related problems and glitches, especially
+ those due to a Zsh "bug" w.r.t. `set -x'.
+ * tests/README: Describe a bug (or at least a weird behaviour) in
+ the way the 4.x versions of Zsh deal with the `-x' a.k.a. `xtrace'
+ switch. This bug can unexpectedly break apparently flawless test
+ scripts. Describe also a workaround for it, involving the use of
+ the new shell function `run_CMD()', defined in tests/defs.in (see
+ below).
+ * tests/defs.in: New subroutine `run_CMD()'. Implementation of
+ subroutine `AUTOMAKE_run()' rewritten to use `run_CMD()'. Unset
+ variable `TEST_LOG_COMPILER', that might cause spurious failures
+ by leaking in the environment of the make processes executed by the
+ test scripts. Updated the code which ensures Bourne-compatibility
+ in Zsh, by adding a call to `setopt NO_GLOB_SUBST' (as done by
+ autoconf 2.64).
+ * tests/acloca14.test:
+ * tests/acloca17.test:
+ * tests/acloca18.test:
+ * tests/aclocal.test:
+ * tests/aclocal3.test:
+ * tests/aclocal8.test:
+ * tests/acsilent.test:
+ * tests/alpha.test:
+ * tests/ammissing.test:
+ * tests/ansi3.test:
+ * tests/ansi3b.test:
+ * tests/check8.test:
+ * tests/cond39.test:
+ * tests/defs.in:
+ * tests/depcomp2.test:
+ * tests/depcomp4.test:
+ * tests/depend5.test:
+ * tests/depend6.test:
+ * tests/discover.test:
+ * tests/distcom3.test:
+ * tests/fn99.test:
+ * tests/fn99subdir.test:
+ * tests/gnits2.test:
+ * tests/gnits3.test:
+ * tests/help.test:
+ * tests/init.test:
+ * tests/instsh.test:
+ * tests/ldadd.test:
+ * tests/libtool7.test:
+ * tests/libtool9.test:
+ * tests/lisp3.test:
+ * tests/ltorder.test:
+ * tests/man4.test:
+ * tests/mdate.test:
+ * tests/missing3.test:
+ * tests/missing4.test:
+ * tests/missing6.test:
+ * tests/obsolete.test:
+ * tests/output-order.test:
+ * tests/pr220.test:
+ * tests/pr300-ltlib.test:
+ * tests/python11.test:
+ * tests/python4.test:
+ * tests/python5.test:
+ * tests/python6.test:
+ * tests/python7.test:
+ * tests/python8.test:
+ * tests/python9.test:
+ * tests/sanity.test:
+ * tests/subobj.test:
+ * tests/subobj9.test:
+ * tests/unused.test:
+ * tests/vars3.test:
+ * tests/version8.test:
+ use new subroutine `run_CMD()' instead of hand-crafted stdout and/or
+ stderr redirections; this, togheter with the changes in file
+ `tests/defs.in', fixes misbehaviour w.r.t. zsh for (at least) the
+ following tests:
+ - aclocal8.test
+ - acsilent.test
+ - depcomp2.test
+ - getopt.test
+ - location.test
+ - missing3.test
+ - output-order.test
+ - parallel-tests3.test
+ - parallel-tests4.test
+ - unused.test
+ - warnopts.test
+ - check9-p.test
+
2009-09-06 Ralf Wildenhues
Avoid sleeping for one second most of the time in sanity check.
diff --git a/tests/README b/tests/README
index b264881..a99a305 100644
--- a/tests/README
+++ b/tests/README
@@ -157,6 +157,29 @@ Do not
reason, but at least it makes sure the original error is still
here.)
+ If you must run a program and later analize its stderr, do *not* run it
+ by doing e.g.:
+ [WRONG] PROG 2>foo.txt
+ Instead, use the run_CMD() subroutine (defined in tests/defs), as in:
+ [GOOD] run_CMD PROG; mv stderr foo.txt
+ You can't use the apparently simpler form `PROG 2>stderr.txt' because of
+ a nasty bug of the zsh shell (at least of some 4.x versions).
+ In details: if you run command when `set -x' is active, and redirect its
+ standard error to a file, then zsh writes also the *trace* for the
+ command into that file, instead that into the original standard error.
+ For example:
+ $ zsh -c -x 'true 2>file'; echo "SHOULD BE EMPTY: `cat file`"
+ SHOULD BE EMPTY: +zsh:1> true
+ while the correct behaviour is e.g.
+ $ ksh -c -x 'true 2>file'; echo "SHOULD BE EMPTY: `cat file`"
+ + true
+ + 2> file
+ SHOULD BE EMPTY:
+ or:
+ $ bash -c -x 'true 2>file'; echo "SHOULD BE EMPTY: `cat file`"
+ + true
+ SHOULD BE EMPTY:
+
Do not override Makefile variables using make arguments, as in
$MAKE ANSI2KNR=./ansi2knr U=_ all
this is not portable for recursive targets (targets that
diff --git a/tests/acloca14.test b/tests/acloca14.test
index 8ddbb1a..6df7c9b 100755
--- a/tests/acloca14.test
+++ b/tests/acloca14.test
@@ -108,5 +108,5 @@ $MAKE testdist2
# Make sure aclocal diagnose missing included files with correct `file:line:'.
rm -f b.m4
-$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+run_CMD -e 1 $ACLOCAL
grep 'a.m4:1:.*b.m4.*does not exist' stderr
diff --git a/tests/acloca17.test b/tests/acloca17.test
index 884f24b..a8326f9 100755
--- a/tests/acloca17.test
+++ b/tests/acloca17.test
@@ -33,7 +33,5 @@ EOF
# FIXME: We want autom4te's 'undefined required macro' warning to be fatal,
# but have no means to say so to aclocal. We use WARNINGS=error instead.
-
-WARNINGS=error $ACLOCAL -I m4 2>stderr && { cat stderr >&2; Exit 1; }
-cat stderr >&2
+run_CMD -e 1 env WARNINGS=error $ACLOCAL -I m4
grep 'configure.in:4:.*UNDEFINED_MACRO' stderr
diff --git a/tests/acloca18.test b/tests/acloca18.test
index 22feb23..e749b73 100755
--- a/tests/acloca18.test
+++ b/tests/acloca18.test
@@ -86,7 +86,7 @@ grep macro23 foo
ACLOCAL_TESTSUITE_FLAGS='-I 4 -I 1 -I 2'
rm -f foo
-$ACLOCAL --install 2>stderr && { cat stderr >&2; Exit 1; }
+run_CMD -e 1 $ACLOCAL --install
grep AM_MACRO2 stderr
ACLOCAL_TESTSUITE_FLAGS='-I 4 -I 1'
@@ -105,9 +105,7 @@ AC_DEFUN([AM_MACRO1], [echo macro1d >> foo])
AC_DEFUN([AM_MACRO2], [echo macro2d >> foo])
EOF
rm -f foo
-$ACLOCAL --diff=diff >output 2>stderr
-cat stderr
-cat output
-grep '#serial 456' output
+run_CMD -e 0 $ACLOCAL --diff=diff
+grep '#serial 456' stdout
test ! -f 4/m1.m4
grep 'installing.*4/m1.m4' stderr
diff --git a/tests/aclocal.test b/tests/aclocal.test
index 6b87a9d..fbb6134 100755
--- a/tests/aclocal.test
+++ b/tests/aclocal.test
@@ -23,15 +23,15 @@ set -e
$ACLOCAL --output=fred
test -f fred
-$ACLOCAL --output 2>stderr && { cat stderr >&2; Exit 1; }
+run_CMD -e 1 $ACLOCAL --output
grep 'option.*--output.*an argument' stderr
grep help stderr
-$ACLOCAL --unknown-option 2>stderr && { cat stderr >&2; Exit 1; }
+run_CMD -e 1 $ACLOCAL --unknown-option
grep 'unrecognized.*--unknown-option' stderr
grep help stderr
-$ACLOCAL --ver 2>stderr && { cat stderr >&2; Exit 1; }
+run_CMD -e 1 $ACLOCAL --ver
grep 'unrecognized.*--ver' stderr
grep help stderr
diff --git a/tests/aclocal3.test b/tests/aclocal3.test
index a550e50..2474304 100755
--- a/tests/aclocal3.test
+++ b/tests/aclocal3.test
@@ -27,6 +27,5 @@ AC_DEFUN([GNOME_X_CHECKS], [
])
END
-$ACLOCAL -I macros 2>stderr
-cat stderr
+run_CMD -e 0 $ACLOCAL -I macros
grep 'macros/gnome.m4:2:.*AM_PATH_GTK.*not found' stderr
diff --git a/tests/aclocal8.test b/tests/aclocal8.test
index ac10aff..935760a 100755
--- a/tests/aclocal8.test
+++ b/tests/aclocal8.test
@@ -34,9 +34,8 @@ EOF
echo 'AC_DEFUN([MACRO1],)' >m4/macro1.m4
echo 'AC_DEFUN([MACRO2], [AC_REQUIRE([AM_UNUSED_MACRO])])' >m4/macro2.m4
-$ACLOCAL -I m4 >output 2>&1
-cat output
-test 0 = `wc -l