From: Stefano Lattarini Date: Wed, 17 Aug 2011 10:06:25 +0000 (+0200) Subject: testsuite: refactor tests on TAP support in view of future changes X-Git-Tag: ng-0.5a~89^2~99^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb21ed841b61c61d70ac9c370f53d2cf53231764;p=thirdparty%2Fautomake.git testsuite: refactor tests on TAP support in view of future changes * tests/defs (fetch_tap_driver): New subroutine; it fetches the automake-provided TAP driver from the `lib/' directory into the current directory, and edits its shebang line so that it will be run with the perl interpreter determined at configure time. * tests/tap-setup.sh: Use it. * tests/tap-common-setup.test: There's no need to AC_SUBST `PERL' anymore, nor to use it in the Makefile to run the TAP driver. Also, use the `fetch_tap_driver' function instead of copying the `tap-driver' auxiliary script directly. * tests/tap-bad-prog.tap: Likewise. * tests/tap-diagnostic-custom.test: Likewise. * tests/tap-doc.test: Likewise. * tests/tap-merge-stdout-stderr.test: Likewise. * tests/tap-more.test: Likewise. * tests/tap-more2.test: Likewise. * tests/tap-recheck.test: Likewise. * tests/tap-summary-aux.sh: Likewise. * tests/tap-basic.test: Likewise, and fix a grammaro in comments since we are at it. --- diff --git a/ChangeLog b/ChangeLog index 2cb53d466..b64124a43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2011-08-17 Stefano Lattarini + + testsuite: refactor tests on TAP support in view of future changes + * tests/defs (fetch_tap_driver): New subroutine; it fetches the + automake-provided TAP driver from the `lib/' directory into the + current directory, and edits its shebang line so that it will be + run with the perl interpreter determined at configure time. + * tests/tap-setup.sh: Use it. + * tests/tap-common-setup.test: There's no need to AC_SUBST `PERL' + anymore, nor to use it in the Makefile to run the TAP driver. + Also, use the `fetch_tap_driver' function instead of copying the + `tap-driver' auxiliary script directly. + * tests/tap-bad-prog.tap: Likewise. + * tests/tap-diagnostic-custom.test: Likewise. + * tests/tap-doc.test: Likewise. + * tests/tap-merge-stdout-stderr.test: Likewise. + * tests/tap-more.test: Likewise. + * tests/tap-more2.test: Likewise. + * tests/tap-recheck.test: Likewise. + * tests/tap-summary-aux.sh: Likewise. + * tests/tap-basic.test: Likewise, and fix a grammaro in comments + since we are at it. + 2011-08-14 Stefano Lattarini coverage: missing tap plan and non-zero exit status diff --git a/tests/defs b/tests/defs index afce3cba9..2b5df6b0a 100644 --- a/tests/defs +++ b/tests/defs @@ -306,6 +306,18 @@ unindent () } sed_unindent_prog="" # Avoid interferences from the environment. +# fetch_tap_driver +# ---------------- +# Fetch the Automake-provided TAP driver from the `lib/' directory into +# the current directory, and edit its shebang line so that it will be +# run with the perl interpreter determined at configure time. +fetch_tap_driver () +{ + sed "1s|#!.*|#! $PERL -w|" "$top_testsrcdir"/lib/tap-driver >tap-driver \ + && chmod a+x tap-driver \ + || fatal_ "failed to fetch perl tap driver" + sed 10q tap-driver # For debugging. +} ## ----------------------------------------------------------- ## ## Checks for required tools, and additional setups (if any) ## diff --git a/tests/tap-bad-prog.tap b/tests/tap-bad-prog.tap index 2dee975a7..c5d37338c 100755 --- a/tests/tap-bad-prog.tap +++ b/tests/tap-bad-prog.tap @@ -21,16 +21,14 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver TESTS = none.test noread.test noexec.test none.test: END diff --git a/tests/tap-basic.test b/tests/tap-basic.test index 26a749d4a..dde65f26f 100755 --- a/tests/tap-basic.test +++ b/tests/tap-basic.test @@ -27,16 +27,14 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver ## Defining LOG_COMPILER should work and not intefere with the ## tap-driver script. TEST_LOG_COMPILER = cat @@ -145,7 +143,7 @@ test `$FGREP -c ': bail.test' stdout` -eq 1 $FGREP 'success.test' stdout && Exit 1 # Override TEST_LOGS from the command line, making it point to a test -# (ok.test) that have to be generated at make time. +# (ok.test) that has to be generated at make time. rm -f *.log *.test diff --git a/tests/tap-common-setup.test b/tests/tap-common-setup.test index de8ff2cbf..f97b5876d 100755 --- a/tests/tap-common-setup.test +++ b/tests/tap-common-setup.test @@ -19,16 +19,14 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in << END -AC_SUBST([PERL], ['$PERL']) AC_OUTPUT END cat > Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver TEST_LOG_COMPILER = cat TESTS = all.test END diff --git a/tests/tap-diagnostic-custom.test b/tests/tap-diagnostic-custom.test index d96522944..88c859ce0 100755 --- a/tests/tap-diagnostic-custom.test +++ b/tests/tap-diagnostic-custom.test @@ -21,16 +21,14 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' -my_log_driver = $(PERL) $(srcdir)/tap-driver +my_log_driver = $(srcdir)/tap-driver my_log_compiler = cat TEST_EXTENSIONS = TESTS = diff --git a/tests/tap-doc.test b/tests/tap-doc.test index 2920d4e2e..8ccd30f62 100755 --- a/tests/tap-doc.test +++ b/tests/tap-doc.test @@ -20,19 +20,17 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' TESTS = foo.sh zardoz.tap bar.sh mu.tap TEST_EXTENSIONS = .sh .tap -TAP_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TAP_LOG_DRIVER = $(srcdir)/tap-driver END cat > foo.sh <<'END' diff --git a/tests/tap-merge-stdout-stderr.test b/tests/tap-merge-stdout-stderr.test index 787ad51f2..4da9f386f 100755 --- a/tests/tap-merge-stdout-stderr.test +++ b/tests/tap-merge-stdout-stderr.test @@ -21,8 +21,7 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat > Makefile.am << 'END' AM_TEST_LOG_DRIVER_FLAGS = --comments --merge diff --git a/tests/tap-more.test b/tests/tap-more.test index 7d0bf86a0..375aa0012 100755 --- a/tests/tap-more.test +++ b/tests/tap-more.test @@ -27,17 +27,15 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver TESTS = 1.test 2.test 3.test EXTRA_DIST = $(TESTS) tap-driver END diff --git a/tests/tap-more2.test b/tests/tap-more2.test index 810f9b86c..f6f1ca1a1 100755 --- a/tests/tap-more2.test +++ b/tests/tap-more2.test @@ -23,19 +23,17 @@ required='cc native' parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' TEST_EXTENSIONS = .sh .tap -tap_driver = $(PERL) $(srcdir)/tap-driver +tap_driver = $(srcdir)/tap-driver LOG_DRIVER = $(tap_driver) SH_LOG_DRIVER = $(tap_driver) diff --git a/tests/tap-recheck.test b/tests/tap-recheck.test index 14b02ad15..0139b0775 100755 --- a/tests/tap-recheck.test +++ b/tests/tap-recheck.test @@ -20,16 +20,14 @@ parallel_tests=yes . ./defs || Exit 1 -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat >> configure.in < Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver TESTS = a.test b.test c.test d.test END diff --git a/tests/tap-setup.sh b/tests/tap-setup.sh index 0d1a1e34e..00397e006 100755 --- a/tests/tap-setup.sh +++ b/tests/tap-setup.sh @@ -31,8 +31,7 @@ test ! -f Makefile.am || mv Makefile.am Makefile.am~ \ test -d ../tap-common-setup.dir && cp -Rp ../tap-common-setup.dir/* . \ || fatal_ "couldn't get precomputed data files" -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver if test -f Makefile.am~; then mv -f Makefile.am~ Makefile.am \ diff --git a/tests/tap-summary-aux.sh b/tests/tap-summary-aux.sh index a5cad5388..7def11dc9 100755 --- a/tests/tap-summary-aux.sh +++ b/tests/tap-summary-aux.sh @@ -26,19 +26,17 @@ case $use_colors in *) fatal_ "invalid \$use_colors value '$use_colors'" esac -cp "$top_testsrcdir"/lib/tap-driver . \ - || fatal_ "failed to fetch auxiliary script tap-driver" +fetch_tap_driver cat > configure.in < Makefile.am << 'END' -TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver +TEST_LOG_DRIVER = $(srcdir)/tap-driver TEST_LOG_COMPILER = cat TESTS = all.test END