[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/8] Testsuite: run_command can now set env variables
From: |
Stefano Lattarini |
Subject: |
[PATCH 7/8] Testsuite: run_command can now set env variables |
Date: |
Mon, 1 Feb 2010 17:46:02 +0100 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.2; i686; ; ) |
Testsuite: run_command can now set env variables
* tests/defs.in (run_command): Now this function can set
additional environment variables for the command it runs;
it does so by properly invoking the `env' utility. Also,
an empty COMMAND argument is now equivalent to specifying
the `env' command. Documentation updated accordingly.
* tests/acloca17.test: Removed now useless `env' calls
from `run_command' invocations.
* tests/check11.test: Likewise.
* tests/check5.test: Likewise.
* tests/check7.test: Likewise.
* tests/check8.test: Likewise.
* tests/cond22.test: Likewise.
* tests/cond30.test: Likewise.
* tests/defs.in: Likewise.
* tests/distdir.test: Likewise.
* tests/exeext.test: Likewise.
* tests/libtool7.test: Likewise.
* tests/libtool9.test: Likewise.
* tests/parallel-tests.test: Likewise.
* tests/parallel-tests2.test: Likewise.
* tests/subst2.test: Likewise.
* tests/suffix11.test: Likewise.
* tests/suffix12.test: Likewise.
* tests/suffix8.test: Likewise.
From 7b600ff8bea4e0fd7f075b61ef06f22b456cf190 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Sat, 30 Jan 2010 19:18:18 +0100
Subject: [PATCH 7/8] Testsuite: run_command can now set env variables
* tests/defs.in (run_command): Now this function can set
additional environment variables for the command it runs;
it does so by properly invoking the `env' utility. Also,
an empty COMMAND argument is now equivalent to specifying
the `env' command. Documentation updated accordingly.
* tests/acloca17.test: Removed now useless `env' calls
from `run_command' invocations.
* tests/check11.test: Likewise.
* tests/check5.test: Likewise.
* tests/check7.test: Likewise.
* tests/check8.test: Likewise.
* tests/cond22.test: Likewise.
* tests/cond30.test: Likewise.
* tests/defs.in: Likewise.
* tests/distdir.test: Likewise.
* tests/exeext.test: Likewise.
* tests/libtool7.test: Likewise.
* tests/libtool9.test: Likewise.
* tests/parallel-tests.test: Likewise.
* tests/parallel-tests2.test: Likewise.
* tests/subst2.test: Likewise.
* tests/suffix11.test: Likewise.
* tests/suffix12.test: Likewise.
* tests/suffix8.test: Likewise.
---
ChangeLog | 29 +++++++++++++++++++++++++++++
tests/acloca17.test | 2 +-
tests/check11.test | 4 ++--
tests/check5.test | 2 +-
tests/check7.test | 2 +-
tests/check8.test | 2 +-
tests/cond22.test | 2 +-
tests/cond30.test | 4 ++--
tests/defs.in | 17 +++++++++++------
tests/distdir.test | 2 +-
tests/exeext.test | 4 ++--
tests/libtool7.test | 6 +++---
tests/libtool9.test | 2 +-
tests/parallel-tests.test | 16 ++++++++--------
tests/parallel-tests2.test | 4 ++--
tests/subst2.test | 4 ++--
tests/suffix11.test | 2 +-
tests/suffix12.test | 2 +-
tests/suffix8.test | 2 +-
19 files changed, 71 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 80aad4d..7a98b1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,34 @@
2010-01-31 Stefano Lattarini <address@hidden>
+ Testsuite: improve function `run_command': now it can set
+ additional environment variables for the command it runs.
+ * tests/defs.in (run_command): Now this function can set
+ additional environment variables for the command it runs;
+ it does so by properly invoking the `env' utility. Also,
+ an empty COMMAND argument is now equivalent to specifying
+ the `env' command. Documentation updated accordingly.
+ * tests/acloca17.test: Removed now useless `env' calls
+ from `run_command' invocations.
+ * tests/check11.test: Likewise.
+ * tests/check5.test: Likewise.
+ * tests/check7.test: Likewise.
+ * tests/check8.test: Likewise.
+ * tests/cond22.test: Likewise.
+ * tests/cond30.test: Likewise.
+ * tests/defs.in: Likewise.
+ * tests/distdir.test: Likewise.
+ * tests/exeext.test: Likewise.
+ * tests/libtool7.test: Likewise.
+ * tests/libtool9.test: Likewise.
+ * tests/parallel-tests.test: Likewise.
+ * tests/parallel-tests2.test: Likewise.
+ * tests/subst2.test: Likewise.
+ * tests/suffix11.test: Likewise.
+ * tests/suffix12.test: Likewise.
+ * tests/suffix8.test: Likewise.
+
+2010-01-31 Stefano Lattarini <address@hidden>
+
Testsuite: prefer use of `run_command' subroutine over "direct"
stdout redirection in some test scripts (unless the latter is
definitely clearer/more convenient).
diff --git a/tests/acloca17.test b/tests/acloca17.test
index ad4fc9c..3620d05 100755
--- a/tests/acloca17.test
+++ b/tests/acloca17.test
@@ -33,5 +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.
-run_command -e 1 env WARNINGS=error $ACLOCAL -I m4
+run_command -e 1 WARNINGS=error $ACLOCAL -I m4
grep 'configure.in:4:.*UNDEFINED_MACRO' stderr
diff --git a/tests/check11.test b/tests/check11.test
index 6307908..d80fe17 100755
--- a/tests/check11.test
+++ b/tests/check11.test
@@ -42,10 +42,10 @@ $AUTOMAKE -a
unset TESTS || :
./configure
-run_command env TESTS=skip $MAKE -e check
+run_command TESTS=skip $MAKE -e check
grep '1.*passed' stdout && Exit 1
-run_command env TESTS="skip skip2" $MAKE -e check
+run_command TESTS="skip skip2" $MAKE -e check
grep '2.*passed' stdout && Exit 1
:
diff --git a/tests/check5.test b/tests/check5.test
index cb87740..78f635b 100755
--- a/tests/check5.test
+++ b/tests/check5.test
@@ -50,7 +50,7 @@ cp one.c two.c
unset TESTS || :
$MAKE check
test -f ok
-run_command env EXEEXT=.bin $MAKE -e 'print-tests'
+run_command EXEEXT=.bin $MAKE -e 'print-tests'
# No am__EXEEXT_* variable is needed.
grep '_EXEEXT_[1-9]' Makefile.in && Exit 1
grep 'BEG: one.bin two.bin :END' stdout
diff --git a/tests/check7.test b/tests/check7.test
index 6fde486..548ef30 100755
--- a/tests/check7.test
+++ b/tests/check7.test
@@ -55,7 +55,7 @@ $AUTOMAKE -a
./configure
$MAKE check
-run_command env EXEEXT=.bin $MAKE -e print-xfail-tests
+run_command EXEEXT=.bin $MAKE -e print-xfail-tests
grep 'BEG: a.bin b c.bin d.bin :END' stdout
$MAKE distclean
diff --git a/tests/check8.test b/tests/check8.test
index 2fbbeb5..ef05430 100755
--- a/tests/check8.test
+++ b/tests/check8.test
@@ -67,7 +67,7 @@ $AUTOMAKE -a
unset TESTS || :
./configure
-run_command -e FAIL -- env AM_COLOR_TESTS=always $MAKE -e check
+run_command -e FAIL AM_COLOR_TESTS=always $MAKE -e check
grep 'XPASS.* foo$' stdout
grep '^[^X]*PASS.* sub/foo$' stdout
grep '^[^X]*PASS.* bar' stdout
diff --git a/tests/cond22.test b/tests/cond22.test
index 11498b3..164e18f 100755
--- a/tests/cond22.test
+++ b/tests/cond22.test
@@ -64,5 +64,5 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure
-run_command env OBJEXT=oo $MAKE -e echo
+run_command OBJEXT=oo $MAKE -e echo
$FGREP 'BEG: one.oo two.oo three.oo three2.oo :END' stdout
diff --git a/tests/cond30.test b/tests/cond30.test
index e2327c5..5259fe5 100755
--- a/tests/cond30.test
+++ b/tests/cond30.test
@@ -44,11 +44,11 @@ $AUTOCONF
$AUTOMAKE
./configure
-run_command env EXEEXT=.foo $MAKE -e print
+run_command EXEEXT=.foo $MAKE -e print
grep 'BEG: a.foo :END' stdout
./configure two=yes
-run_command env EXEEXT=.foo $MAKE -e print
+run_command EXEEXT=.foo $MAKE -e print
grep 'BEG: b.foo :END' stdout
grep 'a_SOURCES = a.c' Makefile.in
diff --git a/tests/defs.in b/tests/defs.in
index 44068bd..80ac1d3 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -399,10 +399,15 @@ is_newest ()
test -z "$is_newest_files"
}
-# 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).
+# run_command [-e STATUS] [-m] [--] [<VAR-1>=<VAL-1> .. <VAR-n>=<VAL-n>]
+# [COMMAND [ARGUMENTS..]]
+# -------------------------------------------------------------------------
+# Run the given COMMAND with ARGUMENTS, and with the <VAR-i> environmental
+# variables added to its environment with the corresponding <VAL-i> values.
+# An empty or missing COMMAND argument is equivalent to specifying the
+# `env' command.
+# Cause the test to FAIL if COMMAND doesn't 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'
@@ -433,8 +438,8 @@ run_command ()
esac
shift
done
- case $# in
- 0) echo "run_command: missing COMMAND argument" >&2; Exit 99;;
+ case ${1-} in
+ ""|*=*) run_cmd=env;;
*) run_cmd=$1; shift;;
esac
# The use of `${1+"$@"}' might trigger a bug of some Korn shells
diff --git a/tests/distdir.test b/tests/distdir.test
index 12b95c9..7986416 100755
--- a/tests/distdir.test
+++ b/tests/distdir.test
@@ -69,7 +69,7 @@ test -d foo && Exit 1
rm -rf distdir-1.0
# Remove the dot from VERSION for the next grep.
-run_command -e IGNORE env VERSION=10 MKDIR_P='echo MKDIR_P' $MAKE -e distdir
+run_command -e IGNORE VERSION=10 MKDIR_P='echo MKDIR_P' $MAKE -e distdir
# Make sure no `./' appear in the directory names. srcdir is `..', so
# this also checks that no directory is created in the source tree.
diff --git a/tests/exeext.test b/tests/exeext.test
index 767ed32..c71b363 100755
--- a/tests/exeext.test
+++ b/tests/exeext.test
@@ -70,7 +70,7 @@ grep 'maude3__EXEEXT__OBJECTS' Makefile.in && Exit 1
./configure
-run_command env EXEEXT=.foo $MAKE -e print
+run_command EXEEXT=.foo $MAKE -e print
grep '1BEG: maude.foo mt.foo :END1' stdout
grep '2BEG: maude.static.foo :END2' stdout
@@ -79,7 +79,7 @@ grep '4BEG: rmt.foo :END4' stdout
./configure revert=yes
-run_command env EXEEXT=.foo $MAKE -e print
+run_command EXEEXT=.foo $MAKE -e print
grep '1BEG: maude.foo :END1' stdout
grep '2BEG: maude.static.foo :END2' stdout
diff --git a/tests/libtool7.test b/tests/libtool7.test
index 70ef249..dbe918a 100755
--- a/tests/libtool7.test
+++ b/tests/libtool7.test
@@ -83,16 +83,16 @@ $AUTOCONF
$AUTOMAKE --add-missing --copy
./configure "--prefix=`pwd`/_inst"
-run_command -m env LIBTOOLFLAGS=--silent $MAKE print
+run_command -m 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
-run_command -m env LIBTOOLFLAGS=--silent $MAKE install
+run_command -m LIBTOOLFLAGS=--silent $MAKE install
grep 'silent.*silent.*prg' stdall
grep 'silent.*silent.*libmod1' stdall
-run_command -m env LIBTOOLFLAGS=--silent $MAKE uninstall
+run_command -m LIBTOOLFLAGS=--silent $MAKE uninstall
grep 'silent.*silent.*libmod1' stdall
diff --git a/tests/libtool9.test b/tests/libtool9.test
index 0a19c74..f759931 100755
--- a/tests/libtool9.test
+++ b/tests/libtool9.test
@@ -88,7 +88,7 @@ $AUTOCONF
$AUTOMAKE --add-missing --copy
./configure
-run_command -m env \
+run_command -m \
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
diff --git a/tests/parallel-tests.test b/tests/parallel-tests.test
index cc90f94..4c477b0 100755
--- a/tests/parallel-tests.test
+++ b/tests/parallel-tests.test
@@ -65,7 +65,7 @@ unset TESTS || :
./configure
# No hard errors: all tests should be run, there should be one failure.
-run_command -e FAIL env DISABLE_HARD_ERRORS=yes $MAKE -e check
+run_command -e FAIL DISABLE_HARD_ERRORS=yes $MAKE -e check
test `grep -c '^FAIL' stdout` -eq 1
test -f mylog.log
test `grep -c '^FAIL' mylog.log` -eq 1
@@ -96,7 +96,7 @@ test `grep -c '^FAIL' mylog.log` -eq 2
# take bar.log into account, because the $(TEST_SUITE_LOG) rule
# does not "see" baz.log. Hmm.
$MAKE clean
-run_command -e FAIL env TESTS='bar.test' $MAKE -e check
+run_command -e FAIL TESTS='bar.test' $MAKE -e check
test -f baz.log
test -f bar.log
test ! -f foo.log
@@ -108,7 +108,7 @@ test -f mylog.log
# Note that the previous test and this one taken together expose the timing
# issue that requires the check-TESTS rule to always remove TEST_SUITE_LOG
# before running the tests lazily.
-run_command -e FAIL env RECHECK_LOGS= $MAKE -e check
+run_command -e FAIL RECHECK_LOGS= $MAKE -e check
cat stdout
test -f foo.log
grep foo.test stdout
@@ -118,32 +118,32 @@ grep '2.*tests.*failed' stdout
# Now, explicitly retry with all test logs already updated, and ensure
# that the summary is still displayed.
-run_command -e FAIL env RECHECK_LOGS= $MAKE -e check
+run_command -e FAIL RECHECK_LOGS= $MAKE -e check
grep foo.test stdout && Exit 1
grep bar.test stdout && Exit 1
grep baz.test stdout && Exit 1
grep '2.*tests.*failed' stdout
# Lazily rerunning only foo should only rerun this one test.
-run_command -e FAIL env RECHECK_LOGS=foo.log $MAKE -e check
+run_command -e FAIL RECHECK_LOGS=foo.log $MAKE -e check
grep foo.test stdout
grep bar.test stdout && Exit 1
grep baz.test stdout && Exit 1
grep '2.*tests.*failed' stdout
# Test VERBOSE.
-run_command -e FAIL env VERBOSE=yes $MAKE -e check
+run_command -e FAIL VERBOSE=yes $MAKE -e check
grep 'this is.*bar.test' stdout
grep 'this is.*baz.test' stdout
$MAKE clean
-run_command -e FAIL env TEST_LOGS=baz.log $MAKE -e check
+run_command -e FAIL TEST_LOGS=baz.log $MAKE -e check
grep foo.test stdout && Exit 1
grep bar.test stdout && Exit 1
grep baz.test stdout
$MAKE clean
-run_command -e FAIL env TESTS=baz.test $MAKE -e check
+run_command -e FAIL TESTS=baz.test $MAKE -e check
grep foo.test stdout && Exit 1
grep bar.test stdout && Exit 1
grep baz.test stdout
diff --git a/tests/parallel-tests2.test b/tests/parallel-tests2.test
index 8d66313..a49d39c 100755
--- a/tests/parallel-tests2.test
+++ b/tests/parallel-tests2.test
@@ -64,12 +64,12 @@ test -f mylog.html
# Always create the HTML output, even if there were no failures.
rm -f mylog.html
-run_command env TESTS=foo.test $MAKE -e check-html
+run_command TESTS=foo.test $MAKE -e check-html
test -f mylog.html
# Create HTML output also with recheck-html
rm -f mylog.html
-run_command env TESTS=foo.test $MAKE -e recheck-html
+run_command TESTS=foo.test $MAKE -e recheck-html
test -f mylog.html
# check-html and recheck-html should cause check_SCRIPTS to be created,
diff --git a/tests/subst2.test b/tests/subst2.test
index 3ca49d7..74bba8b 100755
--- a/tests/subst2.test
+++ b/tests/subst2.test
@@ -42,9 +42,9 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure
-run_command env EXEEXT=.bin $MAKE print-programs
+run_command EXEEXT=.bin $MAKE print-programs
grep 'BEG: x.bin :END' stdout
-run_command env EXEEXT=.bin am__empty=X $MAKE -e print-programs
+run_command EXEEXT=.bin am__empty=X $MAKE -e print-programs
grep 'BEG: x.bin X :END' stdout
# Test for another bug, where EXTRA_PROGRAMS was removed because it was empty.
diff --git a/tests/suffix11.test b/tests/suffix11.test
index 417e0f1..21591ca 100755
--- a/tests/suffix11.test
+++ b/tests/suffix11.test
@@ -52,7 +52,7 @@ grep 'Inference rules can have only one target before the
colon' stderr
# But this should work anyway.
$AUTOMAKE -a -Wno-portability
./configure
-run_command env OBJEXT=foo $MAKE -e print
+run_command OBJEXT=foo $MAKE -e print
grep 'BEGIN: foo.foo :END' stdout
grep 'BEGIN: bar.foo :END' stdout
grep 'BEGIN: baz1.foo baz2.foo :END' stdout
diff --git a/tests/suffix12.test b/tests/suffix12.test
index 84d089e..6abc4f9 100755
--- a/tests/suffix12.test
+++ b/tests/suffix12.test
@@ -47,5 +47,5 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
-run_command env OBJEXT=OBJ $MAKE -e print
+run_command OBJEXT=OBJ $MAKE -e print
grep 'BEGIN: foo.OBJ sub/bar.OBJ :END' stdout
diff --git a/tests/suffix8.test b/tests/suffix8.test
index 52fabf2..6fd9d05 100755
--- a/tests/suffix8.test
+++ b/tests/suffix8.test
@@ -69,7 +69,7 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
-run_command env OBJEXT=foo $MAKE -e print
+run_command OBJEXT=foo $MAKE -e print
grep 'BEGIN: foo.foo :END' stdout
grep 'BEGIN: bar.lo :END' stdout
$MAKE test
--
1.6.5
- [PATCH 0/8] Towards a Zsh-compatible Automake testsuite, Stefano Lattarini, 2010/02/01
- [PATCH 1/8] Testsuite: avoid Zsh-related problem with `set -x', Stefano Lattarini, 2010/02/01
- [PATCH 2/8] Maintainer-check: warn against zsh xtrace bug, Stefano Lattarini, 2010/02/01
- [PATCH 3/8] Testsuite: remove AUTOMAKE_fails and AUTOMAKE_run, Stefano Lattarini, 2010/02/01
- [PATCH 4/8] Work around a bug of AT&T Ksh w.r.t. ${1+"$@"}, Stefano Lattarini, 2010/02/01
- [PATCH 5/8] Improve description of `run_command' in README, Stefano Lattarini, 2010/02/01
- [PATCH 6/8] Tests: prefer run_command over direct stdout redirection(s), Stefano Lattarini, 2010/02/01
- [PATCH 7/8] Testsuite: run_command can now set env variables,
Stefano Lattarini <=
- [PATCH 8/8] Testsuite: avoid redundant use of the `env' utility., Stefano Lattarini, 2010/02/01