From: Stefano Lattarini Date: Fri, 6 Jan 2012 11:39:24 +0000 (+0100) Subject: tests: skip tests on perl TAP driver if TAP::Parser is not available X-Git-Tag: ng-0.5a~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61168e3c4c511e71ae8659388fe7ef8293222dbd;p=thirdparty%2Fautomake.git tests: skip tests on perl TAP driver if TAP::Parser is not available We had so far taken for granted that all the perl installations modern enough to correctly run automake also came with a built-in TAP::Parser module; unfortunately, testing on MinGW/MSYS has shown that this is not always true, and that a lot of spurious testsuite failures would take place in such a situation (see automake bug#10440). Luckily, the perl implementation of the Automake TAP driver is only meant to be used for prototyping and consistency checks, the "real" Automake TAP driver being the portable one implemented in awk. So we can simply skip the affected tests on systems lacking TAP::Parser. * tests/defs (fetch_tap_driver): Skip the whole test case if the desired tap driver implementation is the perl one but the TAP::Parser module is unavailable. * tests/tap-bad-prog.tap: Adjust order of calls to `plan_' and `fetch_tap_driver', to ensure the test is not skipped after the TAP plan has been outputted (which would lead to a spurious error). * tests/tap-bad-signal.tap: Tweak to avoid the need to source the `tap-setup.sh' script, as that might cause a test skip too late, i.e., after a TAP plan has been already printed. * tests/tap-test-number-0.test: Do not force the test to skip when the tested TAP driver implementation is not the perl one. On the other hand, when it *is* the perl one, skip the test if the TAP::Parser module is unavailable. * tests/test-driver-cond.test: Skip the part of the test actually running "make check" if the TAP::Parser module is unavailable. * tests/get-sysconf.test: Also print the version of the `TAP::Parser' module, if available. Reported by Peter Rosin. --- diff --git a/tests/defs b/tests/defs index 835788da8..41ee2625d 100644 --- a/tests/defs +++ b/tests/defs @@ -1,8 +1,8 @@ # -*- shell-script -*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, -# Inc. +# 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 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 @@ -602,12 +602,16 @@ fetch_tap_driver () # TODO: with /bin/sh, for better coverage. case $am_tap_implementation in perl) - sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl ;; + $PERL -MTAP::Parser -e 1 \ + || skip_all_ "cannot import TAP::Parser perl module" + sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl >tap-driver + ;; shell) - sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh ;; + sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh >tap-driver + ;; *) fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;; - esac > tap-driver \ + esac \ && chmod a+x tap-driver \ || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver" sed 10q tap-driver # For debugging. diff --git a/tests/get-sysconf.test b/tests/get-sysconf.test index 039a4369a..789a015f2 100755 --- a/tests/get-sysconf.test +++ b/tests/get-sysconf.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011, 2012 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 @@ -37,6 +37,10 @@ else ' "$top_testsrcdir"/ChangeLog || st=1 fi $PERL -V || st=1 +# It's OK for the user not to have the TAP::Parser module; this can +# happen with older perl installation, or on MinGW/MSYS. +$PERL -e 'use TAP::Parser; print $TAP::Parser::VERSION, "\n"' || : + cat "$top_testbuilddir/config.log" || st=1 cat "$testbuilddir/aclocal-$APIVERSION" || st=1 cat "$testbuilddir/automake-$APIVERSION" || st=1 diff --git a/tests/tap-bad-prog.tap b/tests/tap-bad-prog.tap index a59a1dc3c..212633fc8 100755 --- a/tests/tap-bad-prog.tap +++ b/tests/tap-bad-prog.tap @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011, 2012 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 @@ -21,10 +21,10 @@ am_parallel_tests=yes . ./defs || Exit 1 -plan_ 5 - fetch_tap_driver +plan_ 5 + cat >> configure.in <> configure.in < Makefile.am << END +TEST_LOG_DRIVER = \$(srcdir)/tap-driver TEST_LOG_COMPILER = $PERL -w ## Will be updated later. TESTS = @@ -58,7 +65,11 @@ results_count=`ls *.test | wc -l | tr -d "$tab$sp"` chmod a+x *.test -. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh" +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure signal_caught () { diff --git a/tests/tap-test-number-0.test b/tests/tap-test-number-0.test index 8a117ce2a..6e77a5da3 100755 --- a/tests/tap-test-number-0.test +++ b/tests/tap-test-number-0.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011, 2012 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 @@ -21,23 +21,27 @@ am_parallel_tests=yes . ./defs || Exit 1 -if $PERL -w -e ' - use warnings FATAL => "all"; use strict; - use TAP::Parser; - my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"}); - my $result = $parser->next; - $result->is_plan or die "first line is not TAP plan"; - $result = $parser->next; - $result->is_test or die "second line is not TAP test result"; - my $testno = $result->number; - $parser->next and die "unexpected further TAP stream"; - exit ($testno == 0 ? 0 : 77); -'; then - : # Nothing to do. -elif test $? -eq 77; then - skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1' -else - fatal_ "error analyzing TAP::Parser module for bugs" +if test $am_tap_implementation = perl; then + $PERL -MTAP::Parser -e 1 \ + || skip_ "cannot import TAP::Parser perl module" + if $PERL -w -e ' + use warnings FATAL => "all"; use strict; + use TAP::Parser; + my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"}); + my $result = $parser->next; + $result->is_plan or die "first line is not TAP plan"; + $result = $parser->next; + $result->is_test or die "second line is not TAP test result"; + my $testno = $result->number; + $parser->next and die "unexpected further TAP stream"; + exit ($testno == 0 ? 0 : 77); + '; then + : # Nothing to do. + elif test $? -eq 77; then + skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1' + else + fatal_ "error analyzing TAP::Parser module for bugs" + fi fi . "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh" diff --git a/tests/test-driver-cond.test b/tests/test-driver-cond.test index 3ed48a97b..46986ff10 100755 --- a/tests/test-driver-cond.test +++ b/tests/test-driver-cond.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011, 2012 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 @@ -87,6 +87,9 @@ grep '^my_LOG_DRIVER *=' Makefile.in \ grep '^TEST_LOG_DRIVER =.*\$(SHELL).*/test-driver' Makefile.in +$PERL -MTAP::Parser -e 1 \ + || skip_ "cannot import TAP::Parser perl module" + ./configure do_count ()