From: Stefano Lattarini Date: Mon, 1 Aug 2011 16:32:17 +0000 (+0200) Subject: testsuite: better granularity in a couple of tests on TAP support X-Git-Tag: ng-0.5a~89^2~155^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79ddf6800c051f0b75b0b4115568644c156351c5;p=thirdparty%2Fautomake.git testsuite: better granularity in a couple of tests on TAP support * tests/tap-summary-aux.sh: New auxiliary script, filled with code moved out from ... * tests/tap-summary.test: ... this test, from which the checks on colored testsuite have further been moved into ... * tests/tap-summary-color.test: ... this new test, which in turn * tests/Makefile.am (tap_other_tests): Add `tap-summary-color.test'. (EXTRA_DIST): Distribute `tap-summary-aux.sh' (tap-summary.log): Depend on `tap-summary-aux.sh'. (tap-summary-color.log): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 9c017febf..2f7385d08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-08-01 Stefano Lattarini + + testsuite: better granularity in a couple of tests on TAP support + * tests/tap-summary-aux.sh: New auxiliary script, filled with code + moved out from ... + * tests/tap-summary.test: ... this test, from which the checks on + colored testsuite have further been moved into ... + * tests/tap-summary-color.test: ... this new test, which in turn + * tests/Makefile.am (tap_other_tests): Add `tap-summary-color.test'. + (EXTRA_DIST): Distribute `tap-summary-aux.sh' + (tap-summary.log): Depend on `tap-summary-aux.sh'. + (tap-summary-color.log): Likewise. + 2011-08-01 Stefano Lattarini testsuite: optimize tests on TAP for speed and against duplication diff --git a/tests/Makefile.am b/tests/Makefile.am index 09e5340af..c1c878dcc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1187,7 +1187,11 @@ tap-empty.test \ tap-more.test \ tap-more2.test \ tap-recheck.test \ -tap-summary.test +tap-summary.test \ +tap-summary-color.test + +tap-summary.log tap-summary-color.log: tap-summary-aux.sh +EXTRA_DIST += tap-summary-aux.sh # Dependencies valid for each test case. $(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION) diff --git a/tests/Makefile.in b/tests/Makefile.in index 065a772c8..c3b79eec4 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -276,7 +276,7 @@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = $(parallel_tests) $(instspc_tests) EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \ $(TESTS) trivial-test-driver testsuite-summary-checks.sh \ - extract-testsuite-summary tap-setup.sh + extract-testsuite-summary tap-setup.sh tap-summary-aux.sh XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \ override-conditional-2.test pr8365-remake-timing.test \ yacc-dist-nobuild-subdir.test tap-bad-prog.test \ @@ -1420,7 +1420,8 @@ tap-empty.test \ tap-more.test \ tap-more2.test \ tap-recheck.test \ -tap-summary.test +tap-summary.test \ +tap-summary-color.test all: all-am @@ -1881,6 +1882,8 @@ testsuite-summary-count-many.log: extract-testsuite-summary # Their dependencies. $(tap_with_common_setup_logs): tap-common-setup.log tap-setup.sh +tap-summary.log tap-summary-color.log: tap-summary-aux.sh + # Dependencies valid for each test case. $(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION) diff --git a/tests/tap-summary-aux.sh b/tests/tap-summary-aux.sh new file mode 100755 index 000000000..a5cad5388 --- /dev/null +++ b/tests/tap-summary-aux.sh @@ -0,0 +1,361 @@ +#! /bin/sh +# Copyright (C) 2011 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Auxiliary script for tests on TAP support: checking testsuite summary. + +parallel_tests=yes +. ./defs || Exit 1 + +br='============================================================================' + +case $use_colors in + yes|no) ;; + *) fatal_ "invalid \$use_colors value '$use_colors'" +esac + +cp "$top_testsrcdir"/lib/tap-driver . \ + || fatal_ "failed to fetch auxiliary script tap-driver" + +cat > configure.in < Makefile.am << 'END' +TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_COMPILER = cat +TESTS = all.test +END + +# The following shell variables are influential for this function: +# - expect_failure +# - use_colors +do_check () +{ + case $#,$1 in + 1,--pass) expect_failure=no;; + 1,--fail) expect_failure=yes;; + *) fatal_ "invalid usage of 'do_check'";; + esac + shift + cat > summary.exp + cat all.test + st=0 + if test $use_colors = yes; then + make_cmd="env AM_COLOR_TESTS=always $MAKE -e" + else + make_cmd=$MAKE + fi + $make_cmd check > stdout || st=$? + cat stdout + if test $expect_failure = yes; then + test $st -gt 0 || Exit 1 + else + test $st -eq 0 || Exit 1 + fi + $PERL -w "$testsrcdir"/extract-testsuite-summary stdout > summary.got \ + || fatal_ "cannot extract testsuite summary" + cat summary.exp + cat summary.got + if test $use_colors = yes; then + # Use cmp, not diff, because the files might contain binary data. + compare=cmp + else + compare=diff + fi + $compare summary.exp summary.got || Exit 1 +} + +if test $use_colors = yes; then + red='' + grn='' + lgn='' + blu='' + mgn='' + brg='' + std='' + echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am +else + red= grn= lgn= blu= mgn= brg= std= +fi + + success_header="\ +${grn}${br}${std} +${grn}Testsuite summary for GNU AutoTAP 5.12${std} +${grn}${br}${std}" + + success_footer=${grn}${br}${std} + + failure_header="\ +${red}${br}${std} +${red}Testsuite summary for GNU AutoTAP 5.12${std} +${red}${br}${std}" + + failure_footer="\ +${red}${br}${std} +${red}See ./test-suite.log${std} +${red}Please report to bug-automake@gnu.org${std} +${red}${br}${std}" + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +./configure + +# 1 pass. +{ echo 1..1 && echo ok; } > all.test +do_check --pass < all.test +do_check --pass < all.test +do_check --pass < all.test +do_check --fail < all.test +do_check --fail < all.test +do_check --fail < all.test < all.test < all.test < all.test < all.test < tap + +# Lots of non-failures (300 per kind). +(cat tap && cat tap && cat tap) > all.test +test `wc -l > all.test # Test plan. +do_check --pass < all.test +test `wc -l > all.test # Test plan. +do_check --fail < all.test +test `wc -l > all.test # Test plan. +do_check --fail <. + +# TAP support: +# - colorized testsuite summary + +. ./defs-static + +use_colors=yes +. "$testsrcdir"/tap-summary-aux.sh diff --git a/tests/tap-summary.test b/tests/tap-summary.test index d5c512e50..b49aba71b 100755 --- a/tests/tap-summary.test +++ b/tests/tap-summary.test @@ -15,352 +15,9 @@ # along with this program. If not, see . # TAP support: -# - testsuite summary # - colorized testsuite summary -# TODO: splitting this into two distinct test scripts might be worthwhile -parallel_tests=yes -. ./defs || Exit 1 +. ./defs-static -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" - -cat > configure.in < Makefile.stub << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver -TEST_LOG_COMPILER = cat -TESTS = all.test -END - -$ACLOCAL -$AUTOCONF - -br='============================================================================' - -# The following shell variables are influential for this function: -# - expect_failure -# - use_colors -do_check () -{ - case $#,$1 in - 1,--pass) expect_failure=no;; - 1,--fail) expect_failure=yes;; - *) fatal_ "invalid usage of 'do_check'";; - esac - shift - cat > summary.exp - cat all.test - st=0 - if test $use_colors = yes; then - make_cmd="env AM_COLOR_TESTS=always $MAKE -e" - else - make_cmd=$MAKE - fi - $make_cmd check > stdout || st=$? - cat stdout - if test $expect_failure = yes; then - test $st -gt 0 || Exit 1 - else - test $st -eq 0 || Exit 1 - fi - $PERL -w "$testsrcdir"/extract-testsuite-summary stdout > summary.got \ - || fatal_ "cannot extract testsuite summary" - cat summary.exp - cat summary.got - if test $use_colors = yes; then - # Use cmp, not diff, because the files might contain binary data. - compare=cmp - else - compare=diff - fi - $compare summary.exp summary.got || Exit 1 -} - -for use_colors in "no" "yes"; do - - cp Makefile.stub Makefile.am - - if test $use_colors = yes; then - red='' - grn='' - lgn='' - blu='' - mgn='' - brg='' - std='' - echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am - else - red= grn= lgn= blu= mgn= brg= std= - fi - - success_header="\ -${grn}${br}${std} -${grn}Testsuite summary for GNU AutoTAP 5.12${std} -${grn}${br}${std}" - - success_footer=${grn}${br}${std} - - failure_header="\ -${red}${br}${std} -${red}Testsuite summary for GNU AutoTAP 5.12${std} -${red}${br}${std}" - - failure_footer="\ -${red}${br}${std} -${red}See ./test-suite.log${std} -${red}Please report to bug-automake@gnu.org${std} -${red}${br}${std}" - - $AUTOMAKE --add-missing - - ./configure - - # 1 pass. - { echo 1..1 && echo ok; } > all.test - do_check --pass < all.test - do_check --pass < all.test - do_check --pass < all.test - do_check --fail < all.test - do_check --fail < all.test - do_check --fail < all.test < all.test < all.test < all.test < all.test < tap - - # Lots of non-failures (300 per kind). - (cat tap && cat tap && cat tap) > all.test - test `wc -l > all.test # Test plan. - do_check --pass < all.test - test `wc -l > all.test # Test plan. - do_check --fail < all.test - test `wc -l > all.test # Test plan. - do_check --fail <