Stefano Lattarini wrote: > Aaargh! There is a bug (another), with heirloom-sh this time. > Apparently, shell traces are not enabled/disabled in run_command() > the way they should. > Please do not apply the patch until I'll had figured out and fixed the > problem (I've no time right now, maybe tomorrow I can do something).
That was an easy fix. Apparently, heirloom-sh executes a construct like `{ set +x; } 2>/dev/null' in a subshell, and this of course defies the purpose of the `set +x' directive (which ought to disable shell tracing in the *current* shell). The easy fix is to repeat `set +x' without redirection; this way, heirloom-sh works correctly (even if it displays an extra `+ set +x' on stderr, but this is not a big deal IMHO), while more decent shells continue to have the expected verbosity, and to correctly disable traces. The updated patch is attached. Regards, Stefano
From 4eca77011ccaa38d1491c86d8cfd368d0f851b9c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Fri, 23 Oct 2009 18:27:55 +0200 Subject: [PATCH] Testsuite: avoid Zsh-related problem 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 whose standard error needs to be captured. (save_shell_flags, restore_shell_flags): New functions, used in run_command. (AUTOMAKE_run): Reimplemented using run_command. Updated comment. (AUTOMAKE_fails): Updated comment. * 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/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 | 67 ++++++++++++++++++++++++++ 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 | 119 +++++++++++++++++++++++++++++++++++++++++++---- tests/depcomp2.test | 14 +++-- 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 | 18 ++++++-- 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, 355 insertions(+), 215 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2fe0566..8300a5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,70 @@ +2009-10-23 Stefano Lattarini <stefano.lattar...@gmail.com> + + Testsuite: avoid Zsh-related problem 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 whose standard error needs to be captured. + (save_shell_flags, restore_shell_flags): New functions, used in + run_command. + (AUTOMAKE_run): Reimplemented using run_command. Updated comment. + (AUTOMAKE_fails): Updated comment. + * 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/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-18 Ralf Wildenhues <ralf.wildenh...@gmx.de> Simplify Variable::_check_ambiguous_condition. diff --git a/tests/README b/tests/README index d494b10..0b26211 100644 --- a/tests/README +++ b/tests/README @@ -133,6 +133,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..34c5335 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 -e 1 $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 <output` +run_command -m $ACLOCAL -I m4 +test -s stdall && Exit 1 grep macro1.m4 aclocal.m4 grep macro2.m4 aclocal.m4 && Exit 1 : diff --git a/tests/acsilent.test b/tests/acsilent.test index 6ac7863..e250092 100755 --- a/tests/acsilent.test +++ b/tests/acsilent.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2008 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 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 @@ -32,5 +32,6 @@ module=[$1] AC_SUBST(module)]) END -$ACLOCAL > output 2>&1 || { cat output; Exit 1; } -test -z "`cat output`" +run_command -m $ACLOCAL +test -s stdall && Exit 1 +: diff --git a/tests/alpha.test b/tests/alpha.test index 1ee8ed6..1410b9d 100755 --- a/tests/alpha.test +++ b/tests/alpha.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1998, 2001, 2002, 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 1998, 2001, 2002, 2003, 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 @@ -62,8 +62,7 @@ $AUTOMAKE ./configure # make distdir should fail because NEWS does not mention 1.0a -$MAKE check 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL $MAKE check grep 'NEWS not updated' stderr test ! -f works diff --git a/tests/ammissing.test b/tests/ammissing.test index 61d360a..42aa481 100755 --- a/tests/ammissing.test +++ b/tests/ammissing.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1997, 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 1997, 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 @@ -20,6 +20,5 @@ echo AM_ZARDOZ >> configure.in -$ACLOCAL 2>stderr -cat stderr +run_command -e 1 $ACLOCAL grep 'configure.in:.*AM_ZARDOZ.*not found' stderr diff --git a/tests/ansi3.test b/tests/ansi3.test index 2bbcaf7..95e4fc1 100755 --- a/tests/ansi3.test +++ b/tests/ansi3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999, 2001, 2002, 2003, 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 @@ -53,8 +53,7 @@ export CFLAGS # Linux boxes (Red Hat 5.1 in particular). $ACLOCAL $AUTOCONF -$AUTOMAKE -a 2>stderr -cat stderr +run_command $AUTOMAKE -a grep 'Makefile.am:1:.*ansi2knr\.c' stderr CC='gcc' ./configure ANSI2KNR=./ansi2knr U=_ $MAKE -e diff --git a/tests/ansi3b.test b/tests/ansi3b.test index 8f254ad..447b690 100755 --- a/tests/ansi3b.test +++ b/tests/ansi3b.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999, 2001, 2002, 2003, 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 @@ -52,8 +52,7 @@ export CFLAGS # Linux boxes (Red Hat 5.1 in particular). $ACLOCAL $AUTOCONF -$AUTOMAKE -a 2>stderr -cat stderr +run_command $AUTOMAKE -a grep 'configure.in:2:.*ansi2knr\.1' stderr CC='gcc' ./configure ANSI2KNR=./ansi2knr U=_ $MAKE -e diff --git a/tests/ccnoco3.test b/tests/ccnoco3.test index 2e9cd37..93731a1 100755 --- a/tests/ccnoco3.test +++ b/tests/ccnoco3.test @@ -74,8 +74,7 @@ CC=`pwd`/../Mycomp export CC ../configure -$MAKE 2>stderr || { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command $MAKE grep 'mv.*the same file' stderr && Exit 1 Exit 0 diff --git a/tests/check8.test b/tests/check8.test index 7936582..a087cb7 100755 --- a/tests/check8.test +++ b/tests/check8.test @@ -67,10 +67,7 @@ $AUTOMAKE -a unset TESTS || : ./configure -AM_COLOR_TESTS=always $MAKE -e check >stdout 2>stderr && - { cat stdout; cat stderr >&2; Exit 1; } -cat stdout -cat stderr >&2 +run_command -e FAIL -- env AM_COLOR_TESTS=always $MAKE -e check grep 'XPASS.* foo$' stdout grep '^[^X]*PASS.* sub/foo$' stdout grep '^[^X]*PASS.* bar' stdout @@ -87,8 +84,7 @@ $MAKE distclean mkdir build cd build ../configure -$MAKE check >stdout && { cat stdout; Exit 1; } -cat stdout +run_command -e FAIL $MAKE check # Note: we are not grepping for the space here, due to the Solaris make VPATH # rewriting (if we fix that, we can still write a separate test for it). grep 'XPASS.*foo$' stdout diff --git a/tests/cond39.test b/tests/cond39.test index 79eaa70..1e44866 100755 --- a/tests/cond39.test +++ b/tests/cond39.test @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 2008, 2009 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -82,8 +82,7 @@ $AUTOCONF $AUTOMAKE --add-missing ./configure COND=true -$MAKE 2>stderr -cat stderr +run_command $MAKE grep 'overriding commands' stderr && Exit 1 $MAKE sure-exist ./prog1 && Exit 1 @@ -97,8 +96,7 @@ $MAKE sure-exist $MAKE distclean ./configure COND=false -$MAKE 2>stderr -cat stderr +run_command $MAKE grep 'overriding commands' stderr && Exit 1 ./prog1 ./sub/prog2 diff --git a/tests/defs.in b/tests/defs.in index 6eec344..530f1e0 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -399,26 +399,127 @@ is_newest () test -z "$is_newest_files" } +# save_shell_flags [VAR-BASENAME] +# ------------------------------- +# Save current shell flags in variable VAR_saved_shell_flags +# (default: _saved_shell_flags) +save_shell_flags () +{ + eval "${1}_saved_shell_flags=\$-"; +} + +# restore_shell_flags [VAR] +# ------------------------- +# Restore shell flags saved in variable VAR_saved_shell_flags +# (default: _saved_shell_flags) +restore_shell_flags () +{ + eval set -\${"${1}_saved_shell_flags"} +} + +# run_command [-e STATUS] [-m] [--] COMMAND [ARGUMENTS..] +# ------------------------------------------------------- +# Run the given COMMAND with ARGUMENTS, and cause the test to FAIL if +# COMMAND does not exit with STATUS (more details are given below). +# Also, save standard output and standard error from COMMAND, by default +# respectively in files `stdout' and `stderr' (in the current directory), +# or together in the file `stdall' (in the current directory) if the `-m' +# option is given. +# If STATUS is numeric, the exit value of COMMAND must match it exactly. +# If STATUS is "FAIL" or "FAILURE", then any exit value of COMMAND *but 0* +# is acceptable. If STATUS is "IGNORE" or "IGNORED", any exit value of +# COMMAND is acceptable, and run_command returns with success regardless +# of that value. Finally, if STATUS is "RETURN", any exit value of COMMAND +# is acceptable, *and* such exit value is returned by run_command. +# Default STATUS is `0'. +run_command () +{ + save_shell_flags 'run_command' + set +x # xtrace verbosity temporarly disabled in this function + run_exitcode_expected=0 + run_mix_stdout_and_stderr=no + while test $# -gt 0; do + case $1 in + -e) run_exitcode_expected=$2; shift;; + -m) run_mix_stdout_and_stderr=yes;; + --) shift; break;; + -?) echo "run_commmand: invalid switch \`$1'" >&2; Exit 99;; + *) break;; + esac + shift + done + case $# in + 0) echo "run_command: missing COMMAND argument" >&2; Exit 99;; + *) run_cmd=$1; shift;; + esac + if test x"$run_mix_stdout_and_stderr" = x"yes"; then + run_evald_cmd='"$run_cmd" ${1+"$@"} >stdall 2>&1' + else + run_evald_cmd='"$run_cmd" ${1+"$@"} >stdout 2>stderr' + fi + # NOTE: do not use the apparently simpler construct: + # if eval "$run_evald_cmd"; then + # run_exitcode_got=0 + # else + # run_exitcode_got=$? + # fi + # as FreeBSD /bin/sh chokes on it when `set -e' is on. + if (eval "exec $run_evald_cmd"); then + run_exitcode_got=0 + else + run_exitcode_got=$? + fi + if test x"$run_mix_stdout_and_stderr" = x"yes"; then + set -x + cat stdall + else + set -x + cat stderr >&2 + cat stdout + fi + # Apparently, the `set +x' with redirected stderr is executed in a + # subshell by Solaris Sh, so repeat it without redirection. + { set +x; } 2>/dev/null; set +x + case $run_exitcode_expected in + RETURN|return) + restore_shell_flags 'run_command' + return $run_exitcode_got # RETURN POINT HERE + ;; + IGNORE|ignore|IGNORED|ignored|$run_exitcode_got) + run_ok=yes + ;; + FAIL|fail|FAILURE|failure) + if test $run_exitcode_got -gt 0; then + run_ok=yes + else + run_ok=no + fi + ;; + *) + run_ok=no + ;; + esac + echo "run_command: exit status $run_exitcode_got (expecting" \ + "$run_exitcode_expected)" + restore_shell_flags 'run_command' + test x"$run_ok" = x"yes" || Exit 1 +} # AUTOMAKE_run status [options...] # -------------------------------- -# Run Automake with OPTIONS, and fail if automake +# Run Automake with OPTIONS, and cause the test to FAIL if automake # does not exit with STATUS. AUTOMAKE_run () { - expected_exitcode=$1 + am_run_expected_exitcode=$1 shift - exitcode=0 - $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$? - cat stderr >&2 - cat stdout - test $exitcode = $expected_exitcode || Exit 1 + run_command -e $am_run_expected_exitcode -- $AUTOMAKE ${1+"$@"} } # AUTOMAKE_fails [options...] # --------------------------- -# Run Automake with OPTIONS, and fail if automake -# does not exit with STATUS. +# Run Automake with OPTIONS, and cuse the test to FAIL if automake +# does not exit with status 1. AUTOMAKE_fails () { AUTOMAKE_run 1 ${1+"$@"} diff --git a/tests/depcomp2.test b/tests/depcomp2.test index 4653c90..0daf2f0 100755 --- a/tests/depcomp2.test +++ b/tests/depcomp2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 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 @@ -20,6 +20,8 @@ required=gcc . ./defs || Exit 1 +set -e + cat > configure.in << 'END' AC_INIT(subdir/foo.c) AM_INIT_AUTOMAKE(nonesuch, nonesuch) @@ -45,8 +47,8 @@ END CFLAGS= export CFLAGS -$ACLOCAL || Exit 1 -$AUTOMAKE --add-missing || Exit 1 -$AUTOCONF || Exit 1 -./configure CC='gcc' 2>error.log -test -z "`cat error.log`" +$ACLOCAL +$AUTOMAKE --add-missing +$AUTOCONF +run_command ./configure CC='gcc' +test ! -s stderr diff --git a/tests/depcomp4.test b/tests/depcomp4.test index 7d22894..70cbd57 100755 --- a/tests/depcomp4.test +++ b/tests/depcomp4.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 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 @@ -51,7 +51,6 @@ $AUTOMAKE -a grep am_cv_CC_dependencies_compiler_type configure ./configure am_cv_CC_dependencies_compiler_type=makedepend -$MAKE >output 2>&1 -cat output -grep 'unknown directive' output && Exit 1 +run_command -m $MAKE +grep 'unknown directive' stdall && Exit 1 $MAKE grepdeps diff --git a/tests/depend5.test b/tests/depend5.test index 0d9be3b..52e4169 100755 --- a/tests/depend5.test +++ b/tests/depend5.test @@ -65,10 +65,7 @@ for arg in Makefile \ "--file=$name" do rm -rf .deps _deps - ./config.status "$arg" depfiles >stdout 2>stderr || - { cat stdout; cat stderr >&2; Exit 1; } - cat stdout - cat stderr >&2 + run_command ./config.status "$arg" depfiles grep '[Nn]o such file' stderr && Exit 1 if test -n "$depdir"; then diff --git a/tests/depend6.test b/tests/depend6.test index de2adf9..5ce2208 100755 --- a/tests/depend6.test +++ b/tests/depend6.test @@ -39,9 +39,6 @@ END $ACLOCAL $AUTOMAKE $AUTOCONF -./configure --disable-dependency-tracking 2>stderr || { - stat=$?; cat stderr >&2; Exit $stat; -} -cat stderr >&2 -grep shift stderr && Exit 1 +run_command ./configure --disable-dependency-tracking +grep 'shift' stderr && Exit 1 : diff --git a/tests/discover.test b/tests/discover.test index 36293f7..c62f1b4 100755 --- a/tests/discover.test +++ b/tests/discover.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 1997, 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2002, 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,5 +34,6 @@ END : > fsusage.c $ACLOCAL || Exit 1 -$AUTOMAKE 2>&1 | $FGREP fsusage.c || Exit 1 +run_command -e IGNORE -m $AUTOMAKE +$FGREP fsusage.c stdall || Exit 1 Exit 0 diff --git a/tests/distcom3.test b/tests/distcom3.test index 04bf365..fdcc31a 100755 --- a/tests/distcom3.test +++ b/tests/distcom3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2006, 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 @@ END $ACLOCAL # Should not warn about missing README, since it is a target. -$AUTOMAKE --add-missing --gnu >stdout 2>&1 -cat stdout -grep README stdout && Exit 1 +run_command -m $AUTOMAKE --add-missing --gnu +grep README stdall && Exit 1 sed -n -e '/^DIST_COMMON =.*\\$/ { :loop diff --git a/tests/fn99.test b/tests/fn99.test index 982a989..611c767 100755 --- a/tests/fn99.test +++ b/tests/fn99.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 @@ -47,8 +47,7 @@ do touch x done) || Exit 77 -$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL $MAKE dist grep 'filenames are too long' stderr test 2 = `grep 12345678 stderr | wc -l` : diff --git a/tests/fn99subdir.test b/tests/fn99subdir.test index 465f2af..7055e85 100755 --- a/tests/fn99subdir.test +++ b/tests/fn99subdir.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -73,8 +73,7 @@ do touch x done) -$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL $MAKE dist grep 'filenames are too long' stderr test 1 = `grep 12345678 stderr | wc -l` : diff --git a/tests/gnits2.test b/tests/gnits2.test index 4c5d54f..a85b096 100755 --- a/tests/gnits2.test +++ b/tests/gnits2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2007, 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 @@ -105,6 +105,6 @@ cd build ../configure "--prefix=`pwd`/../inst-dir" --program-prefix=p $MAKE all $MAKE test-install -$MAKE -k installcheck 2>stderr || : # Never trust the exit status of make -k. -cat stderr +# Never trust the exit status of make -k. +run_command -e IGNORE $MAKE -k installcheck $MAKE grep-stderr diff --git a/tests/gnits3.test b/tests/gnits3.test index 7a08fb8..4d90684 100755 --- a/tests/gnits3.test +++ b/tests/gnits3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2007, 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 @@ -83,8 +83,8 @@ cd build ../configure "--prefix=`pwd`/../inst-dir" --program-prefix=p $MAKE $MAKE install -$MAKE -k installcheck 2>stderr || : # Never trust the exit status of make -k. -cat stderr +# Never trust the exit status of make -k. +run_command -e IGNORE $MAKE -k installcheck $MAKE grep-stderr # Make sure there is no more error when all targets are exempted. diff --git a/tests/help.test b/tests/help.test index d4d7110..cae8967 100755 --- a/tests/help.test +++ b/tests/help.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2003, 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 @@ -32,7 +32,7 @@ $AUTOMAKE --version $AUTOMAKE --help # aclocal and automake cannot work without configure.ac or configure.in -$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e 1 $ACLOCAL grep configure.ac stderr grep configure.in stderr AUTOMAKE_fails diff --git a/tests/init.test b/tests/init.test index 38ec681..b6a7375 100755 --- a/tests/init.test +++ b/tests/init.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -27,7 +27,17 @@ AM_INIT_AUTOMAKE END # The error message should mension AC_INIT, not AC_PACKAGE_VERSION. -($ACLOCAL && $AUTOCONF) 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +if run_command -e RETURN $ACLOCAL; then + success=yes +else + success=no +fi +if test x"$success" != x"no"; then + mv stderr stder1 + run_command -e RETURN $AUTOCONF || success=no + cat stderr >>stder1 + mv -f stder1 stderr +fi +test x"$success" = x"no" || Exit 1 grep AC_PACKAGE_VERSION stderr && Exit 1 -grep AC_INIT stderr +grep AC_INIT stderr || Exit 1 diff --git a/tests/instsh.test b/tests/instsh.test index 61f5f9e..fe3d485 100755 --- a/tests/instsh.test +++ b/tests/instsh.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1996, 1999, 2001, 2002, 2003, 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 @@ -32,10 +32,9 @@ mv Makefile.am configure.in frob/ cd frob $ACLOCAL -$AUTOMAKE --add-missing > output 2>&1 +run_command -m $AUTOMAKE --add-missing # Only one `/' should appear in the output. -cat output -grep '/.*/' output && Exit 1 +grep '/.*/' stdall && Exit 1 test -f install-sh diff --git a/tests/ldadd.test b/tests/ldadd.test index 005f9d8..0a9907d 100755 --- a/tests/ldadd.test +++ b/tests/ldadd.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2002, 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 @@ -39,5 +39,6 @@ END : > q.c $ACLOCAL || Exit 1 -$AUTOMAKE 2>&1 | grep LDADD || Exit 1 +run_command -e 1 -m $AUTOMAKE +grep LDADD stdall || Exit 1 Exit 0 diff --git a/tests/libtool7.test b/tests/libtool7.test index a2f912f..f8706d9 100755 --- a/tests/libtool7.test +++ b/tests/libtool7.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2007, 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 @@ -82,19 +82,16 @@ $AUTOCONF $AUTOMAKE --add-missing --copy ./configure "--prefix=`pwd`/_inst" -env LIBTOOLFLAGS=--silent $MAKE print >output 2>&1 -cat output -grep '1BEG: libmod1.la mod2.la :END1' output -grep '2BEG: mod2.la :END2' output -grep '3BEG: .*silent.*silent.* :END3' output +run_command -m env LIBTOOLFLAGS=--silent $MAKE print +grep '1BEG: libmod1.la mod2.la :END1' stdall +grep '2BEG: mod2.la :END2' stdall +grep '3BEG: .*silent.*silent.* :END3' stdall test 2 -le `grep mod2_la_LIBTOOLFLAGS Makefile | wc -l` $MAKE -env LIBTOOLFLAGS=--silent $MAKE install >output 2>&1 -cat output -grep 'silent.*silent.*prg' output -grep 'silent.*silent.*libmod1' output +run_command -m env LIBTOOLFLAGS=--silent $MAKE install +grep 'silent.*silent.*prg' stdall +grep 'silent.*silent.*libmod1' stdall -env LIBTOOLFLAGS=--silent $MAKE uninstall >output 2>&1 -cat output -grep 'silent.*silent.*libmod1' output +run_command -m env LIBTOOLFLAGS=--silent $MAKE uninstall +grep 'silent.*silent.*libmod1' stdall diff --git a/tests/libtool9.test b/tests/libtool9.test index c0d9688..94e617b 100755 --- a/tests/libtool9.test +++ b/tests/libtool9.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2005 Free Software Foundation, Inc. +# Copyright (C) 2005, 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 @@ -88,10 +88,11 @@ $AUTOCONF $AUTOMAKE --add-missing --copy ./configure -env LDFLAGS=ldflags AM_LDFLAGS=am_ldflags libmod1_la_LDFLAGS=lm1_la_ldflags \ +run_command -m env \ + LDFLAGS=ldflags AM_LDFLAGS=am_ldflags libmod1_la_LDFLAGS=lm1_la_ldflags \ CFLAGS=cflags AM_CFLAGS=am_cflags prg2_CFLAGS=prg2_cflags \ - $MAKE -e print >output 2>&1 -cat output + $MAKE -e print +mv stdall output grep '1BEG: libmod1.la mod2.la :END1' output grep '2BEG: mod2.la :END2' output grep '3BEG:.* am_cflags cflags .*lm1_la_ldflags ldflags.* :END3' output diff --git a/tests/lisp3.test b/tests/lisp3.test index 809d491..086173d 100755 --- a/tests/lisp3.test +++ b/tests/lisp3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2003, 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 @@ -61,9 +61,8 @@ test -f am-one.elc unique=0a3346e2af8a689b85002b53df09142a $sleep echo "(message \"$unique\")(provide 'am-three)" > am-three.el -$MAKE >output 2>&1 -cat output -grep $unique output +run_command -m $MAKE +grep $unique stdall # It should also work for VPATH-builds. $MAKE distcheck diff --git a/tests/ltorder.test b/tests/ltorder.test index 0f69211..1e6a03a 100755 --- a/tests/ltorder.test +++ b/tests/ltorder.test @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -53,8 +53,7 @@ $AUTOMAKE --add-missing ./configure "--prefix=`pwd`/inst" $MAKE -$MAKE install 2>stderr || { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command $MAKE install grep 'has not been installed' stderr && Exit 1 $MAKE uninstall diff --git a/tests/man4.test b/tests/man4.test index aa86a9e..7424c72 100755 --- a/tests/man4.test +++ b/tests/man4.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -88,11 +88,9 @@ mkdir build cd build ../configure $MAKE -$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL $MAKE dist grep 'install help2man' stderr -$MAKE distcheck 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL $MAKE distcheck grep 'install help2man' stderr rm -f ../help2man diff --git a/tests/mdate.test b/tests/mdate.test index 704b393..e63bff9 100755 --- a/tests/mdate.test +++ b/tests/mdate.test @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2001, 2002, 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 @@ -31,4 +31,5 @@ END : > texinfo.tex $ACLOCAL || Exit 1 -$AUTOMAKE 2>&1 > /dev/null | grep 'required file.*mdate-sh' +run_command -e IGNORED $AUTOMAKE +grep 'required file.*mdate-sh' stderr diff --git a/tests/missing3.test b/tests/missing3.test index 07ef779..9b48368 100755 --- a/tests/missing3.test +++ b/tests/missing3.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 @@ -22,24 +22,24 @@ set -e # b7cb8259 assumed not to exist. -./missing b7cb8259 --version 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing b7cb8259 --version grep . stderr && Exit 1 -./missing b7cb8259 --grep 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing b7cb8259 --grep grep WARNING stderr -./missing --run b7cb8259 --version && Exit 1 -./missing --run b7cb8259 --grep 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing --run b7cb8259 --version +run_command -e FAIL ./missing --run b7cb8259 --grep grep WARNING stderr # missing itself it known to exist :) -./missing ./missing --version 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing ./missing --version grep . stderr && Exit 1 -./missing ./missing --grep 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing ./missing --grep grep WARNING stderr -./missing --run ./missing --version 2>stderr +run_command ./missing --run ./missing --version grep . stderr && Exit 1 -./missing --run ./missing --grep 2>stderr && { cat stderr >&2; Exit 1; } +run_command -e FAIL ./missing --run ./missing --grep grep WARNING stderr && Exit 1 grep Unknown stderr diff --git a/tests/missing4.test b/tests/missing4.test index 1015828..c6c3b7e 100755 --- a/tests/missing4.test +++ b/tests/missing4.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006, 2007, 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 @@ -36,13 +36,11 @@ cmp aclocal.m4 aclocal.tmp && Exit 1 mv aclocal.tmp aclocal.m4 -$MAKE 2>stderr -cat stderr +run_command $MAKE grep 'You have another version of autoconf' stderr grep -c 'aclocal.m4:.*this file was generated for' stderr -$MAKE 2>stderr -cat stderr +run_command $MAKE grep 'You have another version of autoconf' stderr && Exit 1 grep 'aclocal.m4:.*this file was generated for' stderr && Exit 1 diff --git a/tests/missing6.test b/tests/missing6.test index b63a0d1..bf6df2d 100755 --- a/tests/missing6.test +++ b/tests/missing6.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -31,7 +31,7 @@ rm -f configure.in touch Makefile.am $ACLOCAL -$AUTOCONF 2>stderr +run_command $AUTOCONF grep 'You have another version of autoconf' stderr grep 'aclocal.m4:.*this file was generated for' stderr $AUTOMAKE @@ -43,8 +43,7 @@ cmp configure.ac configure.tmp && Exit 1 mv configure.tmp configure.ac -$MAKE 2>stderr -cat stderr +run_command $MAKE grep 'You have another version of autoconf' stderr grep 'aclocal.m4:.*this file was generated for autoconf 9999a' stderr diff --git a/tests/obsolete.test b/tests/obsolete.test index e6601c9..daae69c 100755 --- a/tests/obsolete.test +++ b/tests/obsolete.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2007, 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 @@ -27,7 +27,7 @@ END $PERL -ne '/AU_DEFUN\(\[(\w+)\]/ && print "$1\n"' \ "$testsrcdir/../m4/obsolete.m4" >> obs cat obs >> configure.in -$PERL -ne 'chomp; print "grep $_ stderr || Exit 1\n"; ' obs > obs.1 +$PERL -ne 'chomp; print "grep $_ stdall || Exit 1\n"; ' obs > obs.1 $PERL -ne 'chomp; print "grep $_ configure.in && Exit 1\n"; ' obs > obs.2 # Sanity check. Make sure we have added something to configure.in. @@ -36,7 +36,7 @@ test `cat configure.in | wc -l` -gt 1 || Exit 1 $ACLOCAL || Exit 1 # Expect Autoconf to complain about each of the macros in obs. -$AUTOCONF -Wobsolete >stderr 2>&1 +run_command -m $AUTOCONF -Wobsolete . ./obs.1 # Make sure Autoupdate remove each of these macros. $AUTOUPDATE || Exit 1 diff --git a/tests/output-order.test b/tests/output-order.test index 856baa2..852c194 100755 --- a/tests/output-order.test +++ b/tests/output-order.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -43,13 +43,12 @@ END $ACLOCAL $AUTOCONF rm -f missing install-sh -$AUTOMAKE --add-missing --copy 2>stderr -cat stderr >&2 +run_command $AUTOMAKE --add-missing --copy +mv stderr stder0 for i in 1 2 3 4 5 6; do rm -f missing install-sh INSTALL COPYING + run_command -e IGNORE $AUTOMAKE --add-missing --copy # The grep prevents a Heisenbug with the HP-UX shell and VERBOSE=yes. - $AUTOMAKE --add-missing --copy 2>&1 >/dev/null | - grep -v /dev/null | - diff - stderr + grep -v /dev/null stder0 | diff - stderr done diff --git a/tests/pr220.test b/tests/pr220.test index 25e1f0e..6644d28 100755 --- a/tests/pr220.test +++ b/tests/pr220.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2004, 2008 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -55,6 +55,5 @@ $AUTOMAKE -a cd build # configure should fail since we've done something invalid. -../configure 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAIL ../configure grep NEVER_TRUE stderr diff --git a/tests/pr300-ltlib.test b/tests/pr300-ltlib.test index 01814a9..7ed0a2f 100755 --- a/tests/pr300-ltlib.test +++ b/tests/pr300-ltlib.test @@ -48,8 +48,7 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --copy --add-missing ./configure --prefix "`pwd`/inst" -$MAKE V=1 >stdout -cat stdout +run_command $MAKE V=1 grep 'liba.la .*-rpath .*lib' stdout grep 'liba.la .*-rpath .*lib/subdir' stdout && Exit 1 @@ -58,8 +57,7 @@ grep 'libb.la .*-rpath .*lib/subdir' stdout test -f subdir/liba.la test -f subdir/libb.la -$MAKE install 2>stderr -cat stderr >&2 +run_command $MAKE install grep 'remember.*--finish' stderr && Exit 1 test -f inst/lib/liba.la diff --git a/tests/python11.test b/tests/python11.test index 0f15f37..920de88 100755 --- a/tests/python11.test +++ b/tests/python11.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2004, 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2004, 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 @@ -35,9 +35,7 @@ EOF $ACLOCAL $AUTOCONF -./configure >stdout 2>stderr && { cat stdout; cat stderr >&2; Exit 1; } -cat stdout -cat stderr >&2 +run_command -e FAILURE ./configure grep 'checking for IShouldNotExist1' stdout grep 'checking for IShouldNotExist2' stdout grep 'no suitable Python interpreter found' stderr diff --git a/tests/python4.test b/tests/python4.test index 11bb3ed..3ff44af 100755 --- a/tests/python4.test +++ b/tests/python4.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2003, 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,6 +33,5 @@ $AUTOCONF $AUTOMAKE --add-missing # Simulate no Python -./configure PYTHON=: 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAILURE ./configure PYTHON=: grep 'no suitable Python interpreter found' stderr diff --git a/tests/python5.test b/tests/python5.test index 86f5863..5695876 100755 --- a/tests/python5.test +++ b/tests/python5.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 2003, 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 @@ -34,6 +34,5 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing -./configure 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 +run_command -e FAILURE ./configure grep 'no suitable Python interpreter found' stderr diff --git a/tests/python6.test b/tests/python6.test index eb4fb4d..ed60e03 100755 --- a/tests/python6.test +++ b/tests/python6.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 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,6 +34,5 @@ $AUTOCONF $AUTOMAKE --add-missing # Simulate no Python -./configure PYTHON=: 2>stderr -cat stderr +run_command ./configure PYTHON=: grep 'GREP ME:' stderr diff --git a/tests/python7.test b/tests/python7.test index 62c1a1b..eb6a4dc 100755 --- a/tests/python7.test +++ b/tests/python7.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 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,6 +34,5 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing -./configure 2>stderr -cat stderr +run_command ./configure grep 'GREP ME:' stderr diff --git a/tests/python8.test b/tests/python8.test index a50af22..5f100ab 100755 --- a/tests/python8.test +++ b/tests/python8.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 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 @@ -32,6 +32,5 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing -./configure 2>stderr -cat stderr +run_command ./configure grep 'GREP ME' stderr diff --git a/tests/python9.test b/tests/python9.test index 9b23deb..c0fa7a5 100755 --- a/tests/python9.test +++ b/tests/python9.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 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,6 +33,5 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing -./configure 2>stderr -cat stderr +run_command ./configure grep 'GREP ME' stderr diff --git a/tests/sanity.test b/tests/sanity.test index 1c96c78..1296381 100755 --- a/tests/sanity.test +++ b/tests/sanity.test @@ -36,14 +36,12 @@ cp ../install-sh ../missing . $ACLOCAL $AUTOCONF $AUTOMAKE -./configure 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr +run_command -e FAILURE ./configure grep 'unsafe absolute working directory' stderr cd .. mkdir build cd build -../unsafe$/configure 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr +run_command -e FAILURE ../unsafe$/configure grep 'unsafe srcdir' stderr : diff --git a/tests/subobj.test b/tests/subobj.test index df297f4..9d7882d 100755 --- a/tests/subobj.test +++ b/tests/subobj.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1999, 2001, 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 1999, 2001, 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 @@ -32,8 +32,7 @@ wish_SOURCES = generic/a.c generic/b.c END $ACLOCAL -$AUTOMAKE --add-missing 2>stderr -cat stderr +run_command $AUTOMAKE --add-missing # Make sure compile is installed, and that Automake says so. grep 'install.*compile' stderr test -f compile diff --git a/tests/subobj9.test b/tests/subobj9.test index 99fe6e8..1f68721 100755 --- a/tests/subobj9.test +++ b/tests/subobj9.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004, 2005, 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 @@ -74,8 +74,8 @@ if test -n "`./libtool --help | grep tag=TAG`"; then fi $MAKE -$MAKE distcheck 2>&1 | tee out +run_command -m $MAKE distcheck # GNU Make used to complain that the Makefile contained two rules # for `src/.dirstamp' and `.//src/.dirstamp'. -grep 'overriding commands' out && Exit 1 +grep 'overriding commands' stdall && Exit 1 : diff --git a/tests/unused.test b/tests/unused.test index a5b4da6..68d5613 100755 --- a/tests/unused.test +++ b/tests/unused.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1998, 2002, 2003, 2008 Free Software Foundation, Inc. +# Copyright (C) 1998, 2002, 2003, 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 @@ -29,5 +29,5 @@ AC_DEFUN([MACRO_1_2], echo 12) AC_DEFUN([MACRO_1_2_3], echo 123) END -$ACLOCAL 2> stderr || { cat stderr >&2; Exit 1; } -test -z "`cat stderr`" +run_command $ACLOCAL +test ! -s stderr diff --git a/tests/vars3.test b/tests/vars3.test index 3d10a90..9f11262 100755 --- a/tests/vars3.test +++ b/tests/vars3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 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 @@ -38,8 +38,7 @@ EOF $ACLOCAL # Make sure this warning is print in the `portability' category. -$AUTOMAKE --warnings=no-error,none,portability 2>stderr -cat stderr +run_command $AUTOMAKE --warnings=no-error,none,portability # Lines number are printed in error message. # Use them to make sure errors are diagnosed against the right lines. diff --git a/tests/version8.test b/tests/version8.test index 91b11a0..ffe4a3e 100755 --- a/tests/version8.test +++ b/tests/version8.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2005, 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 @@ -20,6 +20,5 @@ set -e echo 'AM_AUTOMAKE_VERSION([1.9])' >>configure.in -$ACLOCAL 2>stderr && { cat stderr >&2; Exit 0; } -cat stderr >&2 +run_command -e 1 $ACLOCAL $FGREP 'AM_INIT_AUTOMAKE([1.9])' stderr -- 1.6.3.3