From: Stefano Lattarini Date: Sun, 26 May 2013 19:52:32 +0000 (+0200) Subject: tests: use 'run_make' instead of $MAKE output redirection done by hand X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=607550fef8a0e5f3be2bf4ab8d37cae808098541;p=thirdparty%2Fautomake.git tests: use 'run_make' instead of $MAKE output redirection done by hand Change suggested by 'sc_tests_no_run_make_redirect'. * t/am-xargs-map.sh: Avoid redirecting stdout/stderr from make. * t/dist-formats.tap: Likewise. * t/dist-srcdir2.sh: Likewise. * t/no-spurious-install-recursive.sh: Likewise. * t/nostdinc.sh: Likewise. * t/parallel-tests-dynamic.sh: Likewise. * t/parallel-tests-many.sh: Likewise. * t/parallel-tests-unreadable.sh: Likewise. * t/spell.sh: Likewise. * t/spell2.sh: Likewise. * t/spy-pattern-rules.sh: Likewise. * t/spy-var-append.sh: Likewise. * t/stdinc-no-repeated.sh: Likewise. * t/test-extensions-funny-chars.sh: Likewise. * t/test-extensions-invalid.sh: Likewise. * t/var-undef-append.sh: Likewise. * t/vartypos-deps.sh: Likewise. * t/vartypos-whitelist.sh: Likewise. * t/vartypos.sh: Likewise. * t/parallel-tests-concatenated-suffix.sh: Likewise, and in the process, drop now-obsolete workaround for a Solaris /bin/sh bug. * t/test-driver-custom-multitest-recheck2.sh: Avoid redirection of 'run_make' output, use the '-O' option instead. Signed-off-by: Stefano Lattarini --- diff --git a/t/am-xargs-map.sh b/t/am-xargs-map.sh index 7d974849d..c4e581b9f 100644 --- a/t/am-xargs-map.sh +++ b/t/am-xargs-map.sh @@ -66,8 +66,7 @@ args1="0 1 2 3 4 5 6 7 8 9" args2="$args1 $args1" args4="$args2 $args2" -$MAKE .am/nil WARN=yes 2>stderr || { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E .am/nil WARN=yes grep '^Makefile:' stderr # For debugging test $(grep -c "^Makefile:11: $args4$" stderr) -eq 4 test $(grep -c "^Makefile:12: $args4$" stderr) -eq 4 diff --git a/t/dist-formats.tap b/t/dist-formats.tap index ac0410e5c..720318aeb 100644 --- a/t/dist-formats.tap +++ b/t/dist-formats.tap @@ -205,10 +205,8 @@ unset desc skip_reason # Invalid distribution formats. # # ------------------------------- # -command_ok_ "invalid distribution formats [exit status]" eval ' - ! $MAKE dist AM_DIST_FORMATS="foobar tarZ shar" 2>stderr' - -cat stderr >&2 # For debugging. +command_ok_ "invalid distribution formats [exit status]" \ + run_make -E -e FAIL dist AM_DIST_FORMATS="foobar tarZ shar" command_ok_ "invalid distribution formats [error report]" eval ' sed -e "s/^/ /" -e "s/$/ /" stderr >stderr2 \ diff --git a/t/dist-srcdir2.sh b/t/dist-srcdir2.sh index 9af4d94d6..0ff0481cb 100644 --- a/t/dist-srcdir2.sh +++ b/t/dist-srcdir2.sh @@ -38,8 +38,7 @@ cd build ../configure echo bad > filename-that-is-easy-to-grep -$MAKE distdir 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -e FAIL -E distdir grep 'filename-that-is-easy-to-grep' stderr echo good > ../filename-that-is-easy-to-grep diff --git a/t/no-spurious-install-recursive.sh b/t/no-spurious-install-recursive.sh index 2f6cd553a..c9521149a 100644 --- a/t/no-spurious-install-recursive.sh +++ b/t/no-spurious-install-recursive.sh @@ -32,8 +32,7 @@ $AUTOCONF ./configure for t in all check install; do - $MAKE -n $t-recursive 2>stderr && { cat stderr >&2; exit 1; } - cat stderr >&2 + run_make -E -e FAIL -- -n $t-recursive grep " [Nn]o rule to make target.*[\`\"']$t-recursive" stderr done diff --git a/t/nostdinc.sh b/t/nostdinc.sh index f6f146eda..22fbc7a2d 100644 --- a/t/nostdinc.sh +++ b/t/nostdinc.sh @@ -51,8 +51,7 @@ $AUTOMAKE --add-missing mkdir build cd build ../configure -$MAKE V=1 > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O V=1 grep '.*-I *\.' stdout && exit 1 $MAKE clean # Shouldn't be picked up from builddir either. @@ -62,8 +61,7 @@ cd .. # Test with $builddir = $srcdir ./configure -$MAKE V=1 > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O V=1 grep '.*-I *\.' stdout && exit 1 : diff --git a/t/parallel-tests-concatenated-suffix.sh b/t/parallel-tests-concatenated-suffix.sh index ee83af155..337e9f8c9 100644 --- a/t/parallel-tests-concatenated-suffix.sh +++ b/t/parallel-tests-concatenated-suffix.sh @@ -43,13 +43,7 @@ $AUTOMAKE -a for j in '' -j4; do - # Use append mode here to avoid dropping output. See automake bug#11413. - # Also, use 'echo' here to "nullify" the previous contents of 'stdout', - # since Solaris 10 /bin/sh would try to optimize a ':' away after the - # first iteration, even if it is redirected. - echo " " >stdout - $MAKE $j check >>stdout || { cat stdout; exit 1; } - cat stdout + run_make -O $j check count_test_results total=7 pass=7 fail=0 skip=0 xfail=0 xpass=0 error=0 for t in $tests; do grep "^PASS: $t *$" stdout; done diff --git a/t/parallel-tests-dynamic.sh b/t/parallel-tests-dynamic.sh index 3652064b6..49d571712 100644 --- a/t/parallel-tests-dynamic.sh +++ b/t/parallel-tests-dynamic.sh @@ -98,9 +98,7 @@ $AUTOMAKE -a ./configure -$MAKE check > stdout || { cat stdout; exit 1; } -cat stdout - +run_make -O check count_test_results total=13 pass=9 fail=0 xpass=0 xfail=2 skip=2 error=0 grep '^PASS: t/nosuffix$' stdout @@ -120,15 +118,13 @@ grep '^SKIP: mu$' stdout $MAKE mostlyclean test "$(find . -name '*.log')" = ./config.log -$MAKE distcheck > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O distcheck count_test_results total=13 pass=9 fail=0 xpass=0 xfail=2 skip=2 error=0 -$MAKE check tests1='$(wildcard t00*.sh t98?.sh)' \ - tests2='$(shell ./get-tests-list | sed 1d)' \ - TESTS='$(tests1) $(tests2)' \ - > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O check \ + tests1='$(wildcard t00*.sh t98?.sh)' \ + tests2='$(shell ./get-tests-list | sed 1d)' \ + TESTS='$(tests1) $(tests2)' count_test_results total=4 pass=3 fail=0 xpass=0 xfail=1 skip=0 error=0 @@ -144,13 +140,11 @@ $MAKE check TESTS='$(shell echo t00 | sed "s/$$/-foo/") t99' test -f t00-foo.log test -f t99.log -$MAKE check \ - foo='E9E9E' \ - a='t00.err' \ - b='${a:.err=-foo}' \ - TESTS='$(b) t$(subst E,,$(foo)) $(call my_add_dirprefix,t,nosuffix)' \ - > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O check \ + foo='E9E9E' \ + a='t00.err' \ + b='${a:.err=-foo}' \ + TESTS='$(b) t$(subst E,,$(foo)) $(call my_add_dirprefix,t,nosuffix)' count_test_results total=3 pass=2 fail=0 xpass=0 xfail=1 skip=0 error=0 grep '^PASS: t/nosuffix' stdout diff --git a/t/parallel-tests-many.sh b/t/parallel-tests-many.sh index 53899527e..3ed6e7a07 100644 --- a/t/parallel-tests-many.sh +++ b/t/parallel-tests-many.sh @@ -76,8 +76,7 @@ $AUTOCONF $AUTOMAKE -a ./configure -$MAKE check > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O check grep "^# TOTAL: $whole_count$" stdout grep "^# PASS: $whole_count$" stdout @@ -118,31 +117,25 @@ check_three_reruns () $sleep touch $tst-1.test $dir1-1/foo.sh $dir2-1/$tst-1 -$MAKE check AM_LAZY_CHECK=yes > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O check AM_LAZY_CHECK=yes check_three_reruns grep "^# TOTAL: $whole_count$" stdout grep "^# PASS: $whole_count$" stdout # We need to simulate the failure of few tests. -st=0 -$MAKE check TESTS="$tst-1.test $dir1-1/foo.sh $dir2-1/$tst-1" \ - LOG_COMPILER=false > stdout && st=1 -cat stdout -test $(grep -c '^FAIL:' stdout) -eq 3 || st=1 -test $st -eq 0 || fatal_ "couldn't simulate failure of 3 tests" -unset st - -$MAKE recheck > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O -e FAIL check \ + TESTS="$tst-1.test $dir1-1/foo.sh $dir2-1/$tst-1" \ + LOG_COMPILER=false \ + && test $(grep -c '^FAIL:' stdout) -eq 3 \ + || fatal_ "couldn't simulate failure of 3 tests" + +run_make -O recheck check_three_reruns grep "^# TOTAL: 3$" stdout grep "^# PASS: 3$" stdout # We need to simulate the failure of a lot of tests. -$MAKE check LOG_COMPILER=false > stdout && { cat stdout; exit 1; } -cat stdout - +run_make -O -e FAIL check LOG_COMPILER=false grep '^PASS:' stdout && exit 1 # A random sample. grep "^FAIL: $tst-363\.test$" stdout @@ -153,9 +146,7 @@ grep "^FAIL: " stdout > grp sed 20q grp # For debugging. test $(wc -l stdout || { cat stdout; exit 1; } -cat stdout - +run_make -O recheck grep '^FAIL:' stdout && exit 1 # A random sample. grep "^PASS: $tst-363\.test$" stdout @@ -171,8 +162,7 @@ grep "^# PASS: $whole_count$" stdout # "make clean" might ignore some failures (either on purpose or spuriously), # so we prefer to also grep its output to ensure that no "Argument list too # long" error was encountered. -$MAKE clean >output 2>&1 || { cat output; exit 1; } -cat output +run_make -M clean grep -i 'list.* too long' output && exit 1 list_logs | grep . && exit 1 diff --git a/t/parallel-tests-unreadable.sh b/t/parallel-tests-unreadable.sh index 898532d44..0b67018ce 100644 --- a/t/parallel-tests-unreadable.sh +++ b/t/parallel-tests-unreadable.sh @@ -55,8 +55,7 @@ doit () $MAKE check rm -f test-suite.log chmod a-r $* - $MAKE test-suite.log 2>stderr && { cat stderr >&2; exit 1; } - cat stderr >&2 + run_make -E -e FAIL test-suite.log } could_not_read () diff --git a/t/spell.sh b/t/spell.sh index a5f49ce0a..57159c3bd 100644 --- a/t/spell.sh +++ b/t/spell.sh @@ -38,8 +38,7 @@ $AUTOCONF $AUTOMAKE ./configure -$MAKE 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL make LC_ALL=C sed -e 's|^Makefile:[0-9][0-9]*: ||' \ -e 's|.*\.mk:[0-9][0-9]*: ||' \ diff --git a/t/spell2.sh b/t/spell2.sh index b50c3d7dc..6e8421817 100644 --- a/t/spell2.sh +++ b/t/spell2.sh @@ -38,8 +38,7 @@ $AUTOMAKE ./configure -$MAKE 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL LC_ALL=C sed -e 's|^Makefile:[0-9][0-9]*: ||' \ -e 's|.*\.mk:[0-9][0-9]*: ||' \ diff --git a/t/spy-pattern-rules.sh b/t/spy-pattern-rules.sh index 507d584c5..fee25c373 100644 --- a/t/spy-pattern-rules.sh +++ b/t/spy-pattern-rules.sh @@ -85,7 +85,8 @@ test "$(cat barzap)" = .zap test "$(cat bar-mu)" = .-mu # Sanity check. -$MAKE bax && exit 99 -$MAKE bax 2>&1 | grep '^bax: longest stem rule selected!' || exit 99 +run_make -e FAIL -M bax \ + && grep '^bax: longest stem rule selected!' output \ + || fatal_ 'the longest stem rule was not selected' : diff --git a/t/spy-var-append.sh b/t/spy-var-append.sh index 0d5482ba1..14b10cf8b 100644 --- a/t/spy-var-append.sh +++ b/t/spy-var-append.sh @@ -48,7 +48,7 @@ END checkit () { - $MAKE "$@" 2>stderr && test ! -s stderr || { cat stderr >&2; exit 1; } + run_make -E -- "$@" && test ! -s stderr } checkit test1 diff --git a/t/stdinc-no-repeated.sh b/t/stdinc-no-repeated.sh index 40b855d4e..c0df3a0fa 100644 --- a/t/stdinc-no-repeated.sh +++ b/t/stdinc-no-repeated.sh @@ -36,16 +36,14 @@ $AUTOMAKE --add-missing mkdir build cd build ../configure -$MAKE V=1 > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O V=1 grep '.*-I *\. .*-I *\.\. ' stdout grep '.*-I *\. .*-I *\. ' stdout && exit 1 cd .. # Test with $builddir = $srcdir ./configure -$MAKE V=1 > stdout || { cat stdout; exit 1; } -cat stdout +run_make -O V=1 grep '.*-I *\. ' stdout grep '.*-I *\..*-I *\.' stdout && exit 1 diff --git a/t/test-driver-custom-multitest-recheck2.sh b/t/test-driver-custom-multitest-recheck2.sh index eee7a641f..bc512927a 100644 --- a/t/test-driver-custom-multitest-recheck2.sh +++ b/t/test-driver-custom-multitest-recheck2.sh @@ -93,8 +93,7 @@ for vpath in : false; do rm -f *.run : An empty '$(TESTS)' means that no test should be run. - run_make TESTS= recheck >stdout || { cat stdout; exit 1; } - cat stdout + run_make -O TESTS= recheck count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -e a.run test ! -e b.run diff --git a/t/test-extensions-funny-chars.sh b/t/test-extensions-funny-chars.sh index a3a06a216..a19f6e80b 100644 --- a/t/test-extensions-funny-chars.sh +++ b/t/test-extensions-funny-chars.sh @@ -83,8 +83,7 @@ $AUTOMAKE -a ./configure -st=0; $MAKE check >stdout || st=$? -cat stdout +run_make -e IGNORE -O check ls -l cat test-suite.log cat foo.log @@ -94,7 +93,7 @@ grep '@K @K @K' baz.log cat bar.log cat zardoz.log grep 'Hello Zardoz' zardoz.log && exit 1 -test $st -eq 0 || exit 1 +test $am_make_rc -eq 0 count_all $MAKE clean @@ -104,9 +103,7 @@ test ! -f bar.log test ! -f baz.log test ! -f zardoz.log -st=0 -$MAKE check TESTS=zardoz L!NU.X_LOG_COMPILER=/bin/sh >stdout || st=$? -cat stdout +run_make -O check TESTS=zardoz L!NU.X_LOG_COMPILER=/bin/sh count_test_results total=1 pass=0 fail=0 skip=0 xfail=0 xpass=1 error=0 cat test-suite.log test ! -f foo.log @@ -114,19 +111,16 @@ test ! -f bar.log test ! -f baz.log cat zardoz.log grep 'Hello Zardoz' zardoz.log -test $st -gt 0 || exit 1 +test $am_make_rc -eq 0 -$MAKE recheck >stdout || { cat stdout; exit 1; } -cat stdout +run_make -O recheck count_test_results total=1 pass=0 fail=0 skip=0 xfail=1 xpass=0 error=0 grep '^XFAIL: zardoz.l!Nu\.x$' stdout -$MAKE recheck >stdout || { cat stdout; exit 1; } -cat stdout +run_make -O recheck count_test_results total=0 pass=0 fail=0 skip=0 xfail=0 xpass=0 error=0 -$MAKE distcheck >stdout || { cat stdout; exit 1; } -cat stdout +run_make -O distcheck count_all : diff --git a/t/test-extensions-invalid.sh b/t/test-extensions-invalid.sh index fba3aff1f..1918d84c8 100644 --- a/t/test-extensions-invalid.sh +++ b/t/test-extensions-invalid.sh @@ -32,8 +32,7 @@ $AUTOMAKE -a ./configure -$MAKE 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL for suf in mu x1 _ x2; do $FGREP "invalid test extension: '$suf'" stderr done diff --git a/t/var-undef-append.sh b/t/var-undef-append.sh index 179170c00..6a13825d2 100644 --- a/t/var-undef-append.sh +++ b/t/var-undef-append.sh @@ -91,7 +91,7 @@ $AUTOCONF checkit () { - $MAKE "$@" 2>stderr && test ! -s stderr || { cat stderr >&2; exit 1; } + run_make -E -- "$@" && test ! -s stderr } checkit test1 diff --git a/t/vartypos-deps.sh b/t/vartypos-deps.sh index 7837866fa..a1c29e5dc 100644 --- a/t/vartypos-deps.sh +++ b/t/vartypos-deps.sh @@ -85,15 +85,13 @@ $MAKE (cd ok2 && $MAKE) cd ko1 -$MAKE 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL errgrep LOG errgrep TEST_LOG cd .. cd ko2 -$MAKE 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL errgrep SH_LOG errgrep CONFIG errgrep CONFIGSTATUS diff --git a/t/vartypos-whitelist.sh b/t/vartypos-whitelist.sh index ef0e35962..d5ab94102 100644 --- a/t/vartypos-whitelist.sh +++ b/t/vartypos-whitelist.sh @@ -105,14 +105,12 @@ $MAKE distcheck # If we remove the whitelisting, failure ensues. sed '/^AM_VARTYPOS_WHITELIST *=/d' t && mv -f t Makefile.am \ || fatal_ "editing Makefile.am" -$MAKE 2>stderr && { cat stderr; exit 1; } -cat stderr >&2 +run_make -e FAIL -E grep "'copy_LDADD' is defined but no program" stderr grep "'remove_LDADD' is defined but no program" stderr -$MAKE AM_VARTYPOS_WHITELIST=remove_LDADD AM_FORCE_SANITY_CHECK=yes \ - 2>stderr && { cat stderr; exit 1; } -cat stderr >&2 +run_make -e FAIL -E \ + AM_VARTYPOS_WHITELIST=remove_LDADD AM_FORCE_SANITY_CHECK=yes grep "'copy_LDADD' is defined but no program" stderr grep "remove_LDADD" stderr && exit 1 diff --git a/t/vartypos.sh b/t/vartypos.sh index 6c22d6470..2f0c5ad54 100644 --- a/t/vartypos.sh +++ b/t/vartypos.sh @@ -86,8 +86,7 @@ $AUTOCONF $AUTOMAKE -a ./configure -$MAKE nihil 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL nihil $FGREP 'as canonical' stderr \ | $EGREP -v " '(foo|libfoo_a|libbar_la)' " && exit 1 @@ -107,8 +106,7 @@ $MAKE nihil $sleep echo none_SOURCES = >> Makefile.am -$MAKE nihil 2>stderr && { cat stderr >&2; exit 1; } -cat stderr >&2 +run_make -E -e FAIL nihil grep "variable 'none_SOURCES'" stderr grep "'none' as canonical name" stderr