From 84c967dec7f12332879d86c3fbedfd9837f540b6 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 with `set -x'.
* tests/README: Describe Zsh 4.x `set -x' a.k.a. `xtrace' issue and
workaround with run_command.
* tests/defs.in (run_command): New function, to be used for commands
where standard error needs to be captured.
(AUTOMAKE_run): reimplemented using run_command.
* tests/acloca14.test: Use new subroutine run_command instead of
hand-crafted redirections of stdout and/or stderr.
* tests/acloca17.test: Likewise.
* tests/acloca18.test: Likewise.
* tests/aclocal.test: Likewise.
* tests/aclocal3.test: Likewise.
* tests/aclocal8.test: Likewise.
* tests/acsilent.test: Likewise.
* tests/alpha.test: Likewise.
* tests/ammissing.test: Likewise.
* tests/ansi3.test: Likewise.
* tests/ansi3b.test: Likewise.
* tests/ccnoco3.test: Likewise.
* tests/check8.test: Likewise.
* tests/cond39.test: Likewise.
* tests/defs.in: Likewise.
* tests/depcomp2.test: Likewise.
* tests/depcomp4.test: Likewise.
* tests/depend5.test: Likewise.
* tests/depend6.test: Likewise.
* tests/discover.test: Likewise.
* tests/distcom3.test: Likewise.
* tests/fn99.test: Likewise.
* tests/fn99subdir.test: Likewise.
* tests/gnits2.test: Likewise.
* tests/gnits3.test: Likewise.
* tests/help.test: Likewise.
* tests/init.test: Likewise.
* tests/instsh.test: Likewise.
* tests/ldadd.test: Likewise.
* tests/libtool7.test: Likewise.
* tests/libtool9.test: Likewise.
* tests/lisp3.test: Likewise.
* tests/ltorder.test: Likewise.
* tests/man4.test: Likewise.
* tests/mdate.test: Likewise.
* tests/missing3.test: Likewise.
* tests/missing4.test: Likewise.
* tests/missing6.test: Likewise.
* tests/obsolete.test: Likewise.
* tests/output-order.test: Likewise.
* tests/pr220.test: Likewise.
* tests/pr300-ltlib.test: Likewise.
* tests/python11.test: Likewise.
* tests/python4.test: Likewise.
* tests/python5.test: Likewise.
* tests/python6.test: Likewise.
* tests/python7.test: Likewise.
* tests/python8.test: Likewise.
* tests/python9.test: Likewise.
* tests/sanity.test: Likewise.
* tests/subobj.test: Likewise.
* tests/subobj9.test: Likewise.
* tests/unused.test: Likewise.
* tests/vars3.test: Likewise.
* tests/version8.test: Likewise.
---
ChangeLog | 65 +++++++++++++++++++++++++++++++
tests/README | 10 +++++
tests/acloca14.test | 4 +-
tests/acloca17.test | 6 +--
tests/acloca18.test | 10 ++---
tests/aclocal.test | 8 ++--
tests/aclocal3.test | 5 +-
tests/aclocal8.test | 7 +--
tests/acsilent.test | 7 ++-
tests/alpha.test | 5 +-
tests/ammissing.test | 5 +-
tests/ansi3.test | 5 +-
tests/ansi3b.test | 5 +-
tests/ccnoco3.test | 3 +-
tests/check8.test | 8 +---
tests/cond39.test | 8 +--
tests/defs.in | 96 +++++++++++++++++++++++++++++++++++++++-------
tests/depcomp2.test | 9 +++-
tests/depcomp4.test | 7 +--
tests/depend5.test | 5 +--
tests/depend6.test | 7 +--
tests/discover.test | 5 +-
tests/distcom3.test | 7 +--
tests/fn99.test | 5 +-
tests/fn99subdir.test | 5 +-
tests/gnits2.test | 6 +-
tests/gnits3.test | 6 +-
tests/help.test | 4 +-
tests/init.test | 10 +++-
tests/instsh.test | 7 +--
tests/ldadd.test | 5 +-
tests/libtool7.test | 23 +++++------
tests/libtool9.test | 9 ++--
tests/lisp3.test | 7 +--
tests/ltorder.test | 5 +-
tests/man4.test | 8 +--
tests/mdate.test | 5 +-
tests/missing3.test | 18 ++++----
tests/missing4.test | 8 +--
tests/missing6.test | 7 +--
tests/obsolete.test | 6 +-
tests/output-order.test | 11 ++---
tests/pr220.test | 5 +-
tests/pr300-ltlib.test | 6 +--
tests/python11.test | 6 +--
tests/python4.test | 5 +-
tests/python5.test | 5 +-
tests/python6.test | 5 +-
tests/python7.test | 5 +-
tests/python8.test | 5 +-
tests/python9.test | 5 +-
tests/sanity.test | 6 +--
tests/subobj.test | 5 +-
tests/subobj9.test | 6 +-
tests/unused.test | 6 +-
tests/vars3.test | 5 +-
tests/version8.test | 5 +-
57 files changed, 315 insertions(+), 217 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b54cf75..b137f9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,68 @@
+2009-10-08 Stefano Lattarini
+
+ Fix testsuite: avoid Zsh-related problems with `set -x'.
+ * tests/README: Describe Zsh 4.x `set -x' a.k.a. `xtrace' issue
+ and workaround with run_command.
+ * tests/defs.in (run_command): New function, to be used for
+ commands where standard error needs to be captured.
+ (AUTOMAKE_run): reimplemented using run_command.
+ * tests/acloca14.test: Use new subroutine run_command instead
+ of hand-crafted redirections of stdout and/or stderr.
+ * tests/acloca17.test: Likewise.
+ * tests/acloca18.test: Likewise.
+ * tests/aclocal.test: Likewise.
+ * tests/aclocal3.test: Likewise.
+ * tests/aclocal8.test: Likewise.
+ * tests/acsilent.test: Likewise.
+ * tests/alpha.test: Likewise.
+ * tests/ammissing.test: Likewise.
+ * tests/ansi3.test: Likewise.
+ * tests/ansi3b.test: Likewise.
+ * tests/ccnoco3.test: Likewise.
+ * tests/check8.test: Likewise.
+ * tests/cond39.test: Likewise.
+ * tests/defs.in: Likewise.
+ * tests/depcomp2.test: Likewise.
+ * tests/depcomp4.test: Likewise.
+ * tests/depend5.test: Likewise.
+ * tests/depend6.test: Likewise.
+ * tests/discover.test: Likewise.
+ * tests/distcom3.test: Likewise.
+ * tests/fn99.test: Likewise.
+ * tests/fn99subdir.test: Likewise.
+ * tests/gnits2.test: Likewise.
+ * tests/gnits3.test: Likewise.
+ * tests/help.test: Likewise.
+ * tests/init.test: Likewise.
+ * tests/instsh.test: Likewise.
+ * tests/ldadd.test: Likewise.
+ * tests/libtool7.test: Likewise.
+ * tests/libtool9.test: Likewise.
+ * tests/lisp3.test: Likewise.
+ * tests/ltorder.test: Likewise.
+ * tests/man4.test: Likewise.
+ * tests/mdate.test: Likewise.
+ * tests/missing3.test: Likewise.
+ * tests/missing4.test: Likewise.
+ * tests/missing6.test: Likewise.
+ * tests/obsolete.test: Likewise.
+ * tests/output-order.test: Likewise.
+ * tests/pr220.test: Likewise.
+ * tests/pr300-ltlib.test: Likewise.
+ * tests/python11.test: Likewise.
+ * tests/python4.test: Likewise.
+ * tests/python5.test: Likewise.
+ * tests/python6.test: Likewise.
+ * tests/python7.test: Likewise.
+ * tests/python8.test: Likewise.
+ * tests/python9.test: Likewise.
+ * tests/sanity.test: Likewise.
+ * tests/subobj.test: Likewise.
+ * tests/subobj9.test: Likewise.
+ * tests/unused.test: Likewise.
+ * tests/vars3.test: Likewise.
+ * tests/version8.test: Likewise.
+
2009-10-06 Bruno Haible
Ralf Wildenhues
diff --git a/tests/README b/tests/README
index 4068ad6..9b25be9 100644
--- a/tests/README
+++ b/tests/README
@@ -115,6 +115,16 @@ Do
Use $sleep when you have to make sure that some file is newer
than another.
+ To run a program and analyze its stderr, use the run_command function.
+ For example:
+ run_command PROG [ARGS...]
+ grep $pattern stderr
+ or (if you must check that nothing is written on stderr):
+ run_command PROG2 [ARGS...]
+ test ! -s stderr
+ See section "File Descriptors" in the Autoconf manual to understand why
+ this can be useful, or even required.
+
Use `cat' or `grep' to display (part of) files that may be
interesting for debugging, so that when a user send a verbose
output we don't have to ask him for more details. Display stderr
diff --git a/tests/acloca14.test b/tests/acloca14.test
index 8ddbb1a..cf9c484 100755
--- a/tests/acloca14.test
+++ b/tests/acloca14.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2004, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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_command -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..788cb9d 100755
--- a/tests/acloca17.test
+++ b/tests/acloca17.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2004, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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_command -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..7047eea 100755
--- a/tests/acloca18.test
+++ b/tests/acloca18.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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_command -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_command $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..945b363 100755
--- a/tests/aclocal.test
+++ b/tests/aclocal.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1998, 2001, 2002, 2004, 2008 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2001, 2002, 2004, 2008, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,15 +23,15 @@ set -e
$ACLOCAL --output=fred
test -f fred
-$ACLOCAL --output 2>stderr && { cat stderr >&2; Exit 1; }
+run_command -e 1 $ACLOCAL --output
grep 'option.*--output.*an argument' stderr
grep help stderr
-$ACLOCAL --unknown-option 2>stderr && { cat stderr >&2; Exit 1; }
+run_command -e 1 $ACLOCAL --unknown-option
grep 'unrecognized.*--unknown-option' stderr
grep help stderr
-$ACLOCAL --ver 2>stderr && { cat stderr >&2; Exit 1; }
+run_command -e 1 $ACLOCAL --ver
grep 'unrecognized.*--ver' stderr
grep help stderr
diff --git a/tests/aclocal3.test b/tests/aclocal3.test
index a550e50..a6f26a5 100755
--- a/tests/aclocal3.test
+++ b/tests/aclocal3.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2002, 2004, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,6 +27,5 @@ AC_DEFUN([GNOME_X_CHECKS], [
])
END
-$ACLOCAL -I macros 2>stderr
-cat stderr
+run_command $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..4cf7d73 100755
--- a/tests/aclocal8.test
+++ b/tests/aclocal8.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2009 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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