* tests/defs (count_test_results): New function. * tests/check11.test: Use it. * tests/test-driver-custom-multitest.test: Likewise. * tests/test-driver-custom-multitest-recheck.test: Likewise. * tests/test-driver-custom-multitest-recheck2.test: Likewise. * tests/parallel-tests-log-override-recheck.test: Likewise. * tests/parallel-tests-log-override-recheck.test: Likewise. * tests/parallel-tests-no-spurious-summary.test: Likewise, and slightly improve debugging output. * tests/parallel-tests.test: Make use of `count_test_results'. Also, make grepping of "make check" output slightly stricter * tests/parallel-tests9.test: Likewise. * tests/parallel-tests-log-override-2.test: Likewise, and throw in a small optimization. --- ChangeLog | 18 +++++++++ tests/check11.test | 15 +++++++- tests/defs | 37 +++++++++++++++++++ tests/parallel-tests-log-override-2.test | 10 ++--- tests/parallel-tests-log-override-recheck.test | 8 +--- tests/parallel-tests-no-spurious-summary.test | 11 ++---- tests/parallel-tests.test | 13 ++++--- tests/parallel-tests9.test | 17 ++++----- tests/test-driver-custom-multitest-recheck.test | 31 +++++------------ tests/test-driver-custom-multitest-recheck2.test | 31 +++++------------ tests/test-driver-custom-multitest.test | 41 +-------------------- 11 files changed, 113 insertions(+), 119 deletions(-)
diff --git a/ChangeLog b/ChangeLog index cc64b77..d76b071 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2011-07-07 Stefano Lattarini <stefano.lattar...@gmail.com> + tests defs: new auxiliary function 'count_test_results' + * tests/defs (count_test_results): New function. + * tests/check11.test: Use it. + * tests/test-driver-custom-multitest.test: Likewise. + * tests/test-driver-custom-multitest-recheck.test: Likewise. + * tests/test-driver-custom-multitest-recheck2.test: Likewise. + * tests/parallel-tests-log-override-recheck.test: Likewise. + * tests/parallel-tests-log-override-recheck.test: Likewise. + * tests/parallel-tests-no-spurious-summary.test: Likewise, and + slightly improve debugging output. + * tests/parallel-tests.test: Make use of `count_test_results'. + Also, make grepping of "make check" output slightly stricter + * tests/parallel-tests9.test: Likewise. + * tests/parallel-tests-log-override-2.test: Likewise, and throw + in a small optimization. + +2011-07-07 Stefano Lattarini <stefano.lattar...@gmail.com> + parallel-tests: simplify testsuite summary Prefer a more deterministic, "tabular" format for the testsuite summary, always listing the numbers of passed, failed, xfailed, diff --git a/tests/check11.test b/tests/check11.test index 912b619..acd05b0 100755 --- a/tests/check11.test +++ b/tests/check11.test @@ -38,12 +38,23 @@ $AUTOCONF $AUTOMAKE -a ./configure + env TESTS=skip $MAKE -e check >stdout cat stdout -grep '1.*passed' stdout && Exit 1 +if test x"$parallel_tests" = x"yes"; then + count_test_results total=1 pass=0 fail=0 skip=1 xfail=0 xpass=0 error=0 +else + grep '1.*passed' stdout && Exit 1 + : For shells with buggy 'set -e'. +fi env TESTS="skip skip2" $MAKE -e check >stdout cat stdout -grep '2.*passed' stdout && Exit 1 +if test x"$parallel_tests" = x"yes"; then + count_test_results total=2 pass=0 fail=0 skip=2 xfail=0 xpass=0 error=0 +else + grep '2.*passed' stdout && Exit 1 + : For shells with buggy 'set -e'. +fi : diff --git a/tests/defs b/tests/defs index fb0b535..d3f6de0 100644 --- a/tests/defs +++ b/tests/defs @@ -203,6 +203,43 @@ using_gmake () esac } +# count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N +# ----------------------------------------------------------------------- +# Check that a testsuite run driven by the parallel-tests harness has +# had the specified numbers of test results (specified by kind). +# This function assumes that the output of "make check" or "make recheck" +# has been saved in the `stdout' file in the current directory, and its +# log in the `test-suite.log' file. +count_test_results () +{ + # Use a subshell so that we won't pollute the script namespace. + ( + # TODO: Do proper checks on the arguments? + total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR + eval "$@" + # For debugging. + $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || : + rc=0 + # Avoid spurious failures with shells with "overly sensible" + # `errexit' shell flag, such as e.g., Solaris /bin/sh. + set +e + test `grep -c '^PASS:' stdout` -eq $pass || rc=1 + test `grep -c '^XFAIL:' stdout` -eq $xfail || rc=1 + test `grep -c '^SKIP:' stdout` -eq $skip || rc=1 + test `grep -c '^FAIL:' stdout` -eq $fail || rc=1 + test `grep -c '^XPASS:' stdout` -eq $xpass || rc=1 + test `grep -c '^ERROR:' stdout` -eq $error || rc=1 + grep "^# TOTAL: *$total$" stdout || rc=1 + grep "^# PASS: *$pass$" stdout || rc=1 + grep "^# XFAIL: *$xfail$" stdout || rc=1 + grep "^# SKIP: *$skip$" stdout || rc=1 + grep "^# FAIL: *$fail$" stdout || rc=1 + grep "^# XPASS: *$xpass$" stdout || rc=1 + grep "^# ERROR: *$error$" stdout || rc=1 + test $rc -eq 0 + ) +} + commented_sed_unindent_prog=' /^$/b # Nothing to do for empty lines. x # Get x<indent> into pattern space. diff --git a/tests/parallel-tests-log-override-2.test b/tests/parallel-tests-log-override-2.test index 649360c..dfd6f2f 100755 --- a/tests/parallel-tests-log-override-2.test +++ b/tests/parallel-tests-log-override-2.test @@ -67,6 +67,7 @@ do $MAKE -e check >stdout || { cat stdout; Exit 1; } cat stdout ls -l + count_test_results total=2 pass=1 fail=0 skip=1 xfail=0 xpass=0 error=0 cat pass.log cat skip.log cat partial.log @@ -74,14 +75,11 @@ do test ! -f pass2.log test ! -f skip2.log test ! -f fail.log - grep '^PASS: .*pass\.test' stdout - grep '^SKIP: .*skip\.test' stdout + grep '^PASS: pass\.test$' stdout + grep '^SKIP: skip\.test$' stdout $FGREP 'skip.test' partial.log $FGREP '% skipped test %' partial.log - for t in pass2 skip2 fail; do - $FGREP "$t.test" stdout && Exit 1 - $FGREP "$t.test" partial.log && Exit 1 - done + $EGREP '(pass2|skip2|fail)\.test' stdout partial.log && Exit 1 rm -f *.log done diff --git a/tests/parallel-tests-log-override-recheck.test b/tests/parallel-tests-log-override-recheck.test index 613bea1..d8cab8a 100755 --- a/tests/parallel-tests-log-override-recheck.test +++ b/tests/parallel-tests-log-override-recheck.test @@ -65,9 +65,7 @@ TEST_SUITE_LOG=my.log $MAKE -e recheck >stdout \ && { cat stdout; Exit 1; } cat stdout ls -l -grep '^# TOTAL: *2$' stdout -grep '^# FAIL: *1$' stdout -grep '^# ERROR: *1$' stdout +count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1 for x in stdout my.log; do $FGREP foo.test $x && Exit 1 $FGREP bar.test $x @@ -79,9 +77,7 @@ BAZ_EXIT_STATUS=0 TEST_SUITE_LOG=my2.log $MAKE -e recheck >stdout \ && { cat stdout; Exit 1; } cat stdout ls -l -grep '^# TOTAL: *2$' stdout -grep '^# PASS: *1$' stdout -grep '^# ERROR: *1$' stdout +count_test_results total=2 pass=1 fail=0 skip=0 xfail=0 xpass=0 error=1 $FGREP foo.test stdout && Exit 1 $FGREP bar.test stdout $FGREP baz.test stdout diff --git a/tests/parallel-tests-no-spurious-summary.test b/tests/parallel-tests-no-spurious-summary.test index 7fb95f5..9ef7715 100755 --- a/tests/parallel-tests-no-spurious-summary.test +++ b/tests/parallel-tests-no-spurious-summary.test @@ -51,10 +51,11 @@ $AUTOMAKE -a ./configure st=0 -$MAKE check >output 2>&1 || st=$? -cat output +$MAKE check >stdout || st=$? +cat stdout cat test-suite.log cat foo.log +cat bar.log test $st -eq 0 || Exit $st grep '^:test-result:XFAIL$' foo.log @@ -62,10 +63,6 @@ grep '^:test-result: SKIP$' foo.log grep '^:test-result:FAIL$' bar.log grep '^:test-result: XPASS$' bar.log -grep '^# TOTAL: *2$' output -grep '^# PASS: *2$' output -for result in FAIL XFAIL XPASS SKIP ERROR; do - grep "^# $result: *0$" output -done +count_test_results total=2 pass=2 fail=0 skip=0 xfail=0 xpass=0 error=0 : diff --git a/tests/parallel-tests.test b/tests/parallel-tests.test index 44e8846..b67922f 100755 --- a/tests/parallel-tests.test +++ b/tests/parallel-tests.test @@ -68,13 +68,12 @@ $AUTOMAKE -a $MAKE check >stdout && { cat stdout; Exit 1; } cat stdout -# There should be one failure and one hard error. -test `grep -c '^FAIL:' stdout` -eq 1 -test `grep -c '^ERROR:' stdout` -eq 1 +count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1 test -f mylog.log cat mylog.log test `grep -c '^FAIL:' mylog.log` -eq 1 test `grep -c '^ERROR:' mylog.log` -eq 1 +$EGREP '^(X?PASS|XFAIL|SKIP)' mylog.log && Exit 1 test -f baz.log test -f bar.log test -f foo.log @@ -93,7 +92,11 @@ test -f unrelated.log # Note that this usage has a problem: the summary will only # take bar.log into account, because the $(TEST_SUITE_LOG) rule # does not "see" baz.log. Hmm. -env TESTS='bar.test' $MAKE -e check && Exit 1 +env TESTS='bar.test' $MAKE -e check >stdout && { cat stdout; Exit 1; } +cat stdout +grep '^FAIL: baz\.test$' stdout +grep '^ERROR: bar\.test$' stdout + test -f baz.log test -f bar.log test ! -f foo.log @@ -108,7 +111,7 @@ test -f mylog.log env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; } cat stdout test -f foo.log -grep foo.test stdout +grep '^PASS: foo\.test$' stdout grep bar.test stdout && Exit 1 grep baz.test stdout && Exit 1 grep '^# PASS: *1$' stdout diff --git a/tests/parallel-tests9.test b/tests/parallel-tests9.test index 2a6922e..68fd1d4 100755 --- a/tests/parallel-tests9.test +++ b/tests/parallel-tests9.test @@ -58,25 +58,22 @@ $AUTOMAKE -a ./configure $MAKE check >stdout && { cat stdout; Exit 1; } cat stdout -grep '^# PASS: *1$' stdout -grep '^# FAIL: *1$' stdout -grep '^# ERROR: *1$' stdout +count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1 $MAKE recheck >stdout && { cat stdout; Exit 1; } cat stdout -grep foo.test stdout && Exit 1 -grep bar.test stdout || Exit 1 -grep baz.test stdout || Exit 1 -grep '^# PASS: *0$' stdout -grep '^# FAIL: *1$' stdout -grep '^# ERROR: *1$' stdout +count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1 +grep 'foo\.test' stdout && Exit 1 +grep '^ERROR: bar\.test$' stdout +grep '^FAIL: baz\.test$' stdout # If we cannot read the log file, then redo it as well. chmod a-r foo.log if test ! -r foo.log; then $MAKE recheck >stdout && { cat stdout; Exit 1; } cat stdout - grep foo.test stdout || Exit 1 + count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1 + grep '^PASS: foo\.test$' stdout || Exit 1 fi # Ensure that recheck builds check_SCRIPTS, and that diff --git a/tests/test-driver-custom-multitest-recheck.test b/tests/test-driver-custom-multitest-recheck.test index c178fa0..137ff96 100755 --- a/tests/test-driver-custom-multitest-recheck.test +++ b/tests/test-driver-custom-multitest-recheck.test @@ -95,19 +95,6 @@ do_recheck () cat stdout; ls -l } -do_count () -{ - pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR - eval "$@" - $EGREP '(PASS|FAIL|XPASS|XFAIL|SKIP|ERROR)' stdout || : # For debugging. - test `grep -c '^PASS:' stdout` -eq $pass - test `grep -c '^FAIL:' stdout` -eq $fail - test `grep -c '^XPASS:' stdout` -eq $xpass - test `grep -c '^XFAIL:' stdout` -eq $xfail - test `grep -c '^SKIP:' stdout` -eq $skip - test `grep -c '^ERROR:' stdout` -eq $error -} - for vpath in : false; do if $vpath; then mkdir build @@ -130,7 +117,7 @@ for vpath in : false; do test ! -r c.log test ! -r d.run test ! -r d.log - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 : Run the tests for the first time. $MAKE check >stdout && { cat stdout; Exit 1; } @@ -141,7 +128,7 @@ for vpath in : false; do test -f b.run test -f c.run test -f d.run - do_count pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1 + count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1 : Let us make b.test pass. echo OK > b.ok @@ -152,7 +139,7 @@ for vpath in : false; do test -f b.run test -f c.run test -f d.run - do_count pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0 + count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0 : Let us make the first part of c.test pass. echo OK > c.pass @@ -161,7 +148,7 @@ for vpath in : false; do test ! -r b.run test -f c.run test -f d.run - do_count pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0 + count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0 : Let us make also the second part of c.test pass. echo KO > c.xfail @@ -170,7 +157,7 @@ for vpath in : false; do test ! -r b.run test -f c.run test -f d.run - do_count pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0 + count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0 : Nothing changed, so only d.test should be run. for i in 1 2; do @@ -179,7 +166,7 @@ for vpath in : false; do test ! -r b.run test ! -r c.run test -f d.run - do_count pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0 + count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0 done : Let us make d.test run more testcases, and experience _more_ failures. @@ -200,7 +187,7 @@ END test ! -r b.run test ! -r c.run test -f d.run - do_count pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2 + count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2 : Let us finally make d.test pass. echo : > d.extra @@ -209,7 +196,7 @@ END test ! -r b.run test ! -r c.run test -f d.run - do_count pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0 + count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0 : All tests have been successful or skipped, nothing should be re-run. do_recheck --pass @@ -217,7 +204,7 @@ END test ! -r b.run test ! -r c.run test ! -r d.run - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 cd $srcdir diff --git a/tests/test-driver-custom-multitest-recheck2.test b/tests/test-driver-custom-multitest-recheck2.test index 36cb302..ed08675 100755 --- a/tests/test-driver-custom-multitest-recheck2.test +++ b/tests/test-driver-custom-multitest-recheck2.test @@ -72,19 +72,6 @@ $ACLOCAL $AUTOCONF $AUTOMAKE -do_count () -{ - pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR - eval "$@" - $EGREP '(PASS|FAIL|XPASS|XFAIL|SKIP|ERROR)' stdout || : # For debugging. - test `grep -c '^PASS:' stdout` -eq $pass - test `grep -c '^FAIL:' stdout` -eq $fail - test `grep -c '^XPASS:' stdout` -eq $xpass - test `grep -c '^XFAIL:' stdout` -eq $xfail - test `grep -c '^SKIP:' stdout` -eq $skip - test `grep -c '^ERROR:' stdout` -eq $error -} - for vpath in : false; do if $vpath; then mkdir build @@ -103,7 +90,7 @@ for vpath in : false; do test -f a.run test -f b.run test -f c.run - do_count pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0 + count_test_results total=5 pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0 rm -f *.run @@ -111,7 +98,7 @@ for vpath in : false; do for var in TESTS TEST_LOGS; do env "$var=" $MAKE -e recheck >stdout || { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test ! -r c.run @@ -122,7 +109,7 @@ for vpath in : false; do env TESTS=a.test $MAKE -e recheck >stdout \ || { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test ! -r c.run @@ -135,7 +122,7 @@ for vpath in : false; do test ! -r a.run test -f b.run test ! -r c.run - do_count pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0 + count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0 rm -f *.run @@ -143,14 +130,14 @@ for vpath in : false; do TEST_LOGS=b.log $MAKE -e recheck >stdout \ || { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test ! -r c.run TESTS='a.test b.test' $MAKE -e recheck >stdout \ || { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test ! -r c.run @@ -162,7 +149,7 @@ for vpath in : false; do env TEST_LOGS='a.log c.log' $MAKE -e recheck >stdout \ && { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1 + count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1 test ! -r a.run test ! -r b.run test -f c.run @@ -175,7 +162,7 @@ for vpath in : false; do env TESTS='c.test a.test' $MAKE -e recheck >stdout \ || { cat stdout; Exit 1; } cat stdout - do_count pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test -f c.run @@ -186,7 +173,7 @@ for vpath in : false; do : succesful. $MAKE recheck >stdout || { cat stdout; Exit 1; } cat stdout - do_count pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 + count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0 test ! -r a.run test ! -r b.run test ! -r c.run diff --git a/tests/test-driver-custom-multitest.test b/tests/test-driver-custom-multitest.test index 0316f0f..df0568c 100755 --- a/tests/test-driver-custom-multitest.test +++ b/tests/test-driver-custom-multitest.test @@ -43,14 +43,6 @@ TESTS = \ pass-xpass-fail-xfail-skip-error.t END -expected_tests=23 -expected_pass=10 -expected_fail=5 -expected_skip=4 -expected_xfail=2 -expected_xpass=1 -expected_error=1 - cat > pass.t << 'END' echo %% pass %% echo PASS: pass @@ -143,15 +135,8 @@ for vpath in : false; do cat pass4-skip.log cat pass3-skip2-xfail.log cat pass-xpass-fail-xfail-skip-error.log - # For debugging. - $EGREP '(PASS|FAIL|XPASS|XFAIL|SKIP|ERROR)' stdout - test `grep -c '^PASS:' stdout` -eq $expected_pass - test `grep -c '^FAIL:' stdout` -eq $expected_fail - test `grep -c '^XPASS:' stdout` -eq $expected_xpass - test `grep -c '^XFAIL:' stdout` -eq $expected_xfail - test `grep -c '^SKIP:' stdout` -eq $expected_skip - test `grep -c '^ERROR:' stdout` -eq $expected_error + count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1 tst=pass-xpass-fail-xfail-skip-error grep "^PASS: $tst\.t, testcase 1" stdout @@ -161,15 +146,6 @@ for vpath in : false; do grep "^SKIP: $tst\.t, testcase 5" stdout grep "^ERROR: $tst\.t, testcase 6" stdout - # Check counts of testcases in testsuite summary printed on console. - grep "^# TOTAL: *$expected_tests$" stdout - grep "^# PASS: *$expected_pass$" stdout - grep "^# XPASS: *$expected_xpass$" stdout - grep "^# FAIL: *$expected_fail$" stdout - grep "^# XFAIL: *$expected_xfail$" stdout - grep "^# SKIP: *$expected_skip$" stdout - grep "^# ERROR: *$expected_error$" stdout - # Check that the content of, and only of, the test logs with at least # one failing test case has been copied into `test-suite.log'. Note # that test logs containing skipped or failed test cases are *not* @@ -186,20 +162,7 @@ for vpath in : false; do || { cat stdout; cat test-suite.log; Exit 1; } cat test-suite.log cat stdout - # For debugging. - $EGREP '(PASS|FAIL|XPASS|XFAIL|SKIP|ERROR)' stdout - test `grep -c '^PASS:' stdout` -eq 4 - test `grep -c '^SKIP:' stdout` -eq 2 - test `grep -c '^XFAIL:' stdout` -eq 1 - $EGREP '^(FAIL|XPASS|ERROR)' stdout && Exit 1 - # Check counts of testcases in testsuite summary printed on console. - grep "^# TOTAL: *7$" stdout - grep "^# PASS: *4$" stdout - grep "^# XPASS: *0$" stdout - grep "^# FAIL: *0$" stdout - grep "^# XFAIL: *1$" stdout - grep "^# SKIP: *2$" stdout - grep "^# ERROR: *0$" stdout + count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0 cd $srcdir -- 1.7.2.3