]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: skip tests on perl TAP driver if TAP::Parser is not available
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 6 Jan 2012 11:39:24 +0000 (12:39 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 6 Jan 2012 17:36:11 +0000 (18:36 +0100)
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.

tests/defs
tests/get-sysconf.test
tests/tap-bad-prog.tap
tests/tap-signal.tap
tests/tap-test-number-0.test
tests/test-driver-cond.test

index 835788da83cdc89dbaa78b3645bc246368f70283..41ee2625d0e0adfaf9e84cf968cd57ea035c2a59 100644 (file)
@@ -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.
index 039a4369a77db74a6866da1b8d75f181179906c1..789a015f21ffa3fc365ecea146c5003fd91d0622 100755 (executable)
@@ -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
index a59a1dc3c055ee568942113b6914f238c493afaa..212633fc8c9aafde3bec7240e48daf01ed137dd2 100755 (executable)
@@ -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
 am_parallel_tests=yes
 . ./defs || Exit 1
 
-plan_ 5
-
 fetch_tap_driver
 
+plan_ 5
+
 cat >> configure.in <<END
 AC_OUTPUT
 END
index 0ed7194cbb11b9d7fa478f4c2f07cfec30121ad2..f436bc88a639482750bada3177ce79238f05da7c 100755 (executable)
@@ -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
 am_parallel_tests=yes
 . ./defs || Exit 1
 
+fetch_tap_driver
+
 plan_ 10
 
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
 cat > 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 ()
 {
index 8a117ce2a71a16bd8af373e22b349b0a7576ef7a..6e77a5da3c72a6c814ce387004f4a818eefa7f03 100755 (executable)
@@ -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
 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"
index 3ed48a97b27897fe61094085f4210e03c7cf3b9a..46986ff10295caf0f092fb50bfa7c906f8c8f1ab 100755 (executable)
@@ -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 ()