From: Stefano Lattarini Date: Tue, 27 Dec 2011 10:45:59 +0000 (+0100) Subject: tap/awk: "Bail out!" recognized also after leading whitespace X-Git-Tag: ng-0.5a~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fa8a9e975ce30702c87bd827b61f6e59ad98678;p=thirdparty%2Fautomake.git tap/awk: "Bail out!" recognized also after leading whitespace Newer versions of TAP::Harness (e.g., 3.23 on Perl 5.14.1) recognize a "Bail out!" directive also when it is prepended by leading whitespace; this was not the case for older TAP:Harness versions, (e.g., for version 3.17 on Perl 5.12.4), and for our TAP driver implemented in awk. * lib/tap-driver.sh: Handle the "Bail out!" directive also when it is preceded by leading whitespace. * tests/tap-spurious.test: Remove the tests checking that a "Bail out!" string coming right after leading whitespace does not trigger a bailout action. * tests/tap-bailout-leading-space.test: New test. * tests/list-of-tests.mk: Add it. Problem reported by Jim Meyering in automake bug#10374. --- diff --git a/ChangeLog b/ChangeLog index e0122fbe7..d7ff68baa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2011-12-27 Stefano Lattarini + + tap/awk: "Bail out!" recognized also after leading whitespace + Newer versions of TAP::Harness (e.g., 3.23 on Perl 5.14.1) + recognize a "Bail out!" directive also when it is prepended by + leading whitespace; this was not the case for older TAP:Harness + versions, (e.g., for version 3.17 on Perl 5.12.4), and for our + TAP driver implemented in awk. + * lib/tap-driver.sh: Handle the "Bail out!" directive also when + it is preceded by leading whitespace. + * tests/tap-spurious.test: Remove the tests checking that a + "Bail out!" string coming right after leading whitespace does + not trigger a bailout action. + * tests/tap-bailout-leading-space.test: New test. + * tests/list-of-tests.mk: Add it. + Problem reported by Jim Meyering in automake bug#10374. + 2011-12-27 Stefano Lattarini tests: fix spurious failure of cond29.test diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index c911991c1..c0112983b 100755 --- a/lib/tap-driver.sh +++ b/lib/tap-driver.sh @@ -23,7 +23,7 @@ # bugs to or send patches to # . -scriptversion=2011-09-28.14; # UTC +scriptversion=2011-12-27.17; # UTC # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. @@ -573,12 +573,16 @@ while (1) handle_tap_plan(0, $0) } # "Bail out!" magic. - else if ($0 ~ /^Bail out!/) + # Older versions of prove and TAP::Harness (e.g., 3.17) did not + # recognize a "Bail out!" directive when preceded by leading + # whitespace, but more modern versions (e.g., 3.23) do. So we + # emulate the latter, "more modern" behaviour. + else if ($0 ~ /^[ \t]*Bail out!/) { bailed_out = 1 # Get the bailout message (if any), with leading and trailing # whitespace stripped. The message remains stored in `$0`. - sub("^Bail out![ \t]*", ""); + sub("^[ \t]*Bail out![ \t]*", ""); sub("[ \t]*$", ""); # Format the error message for the bailout_message = "Bail out!" diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index 71a7693c5..259b23277 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -1001,6 +1001,7 @@ syntax.test \ tap-ambiguous-directive.test \ tap-autonumber.test \ tap-bailout.test \ +tap-bailout-leading-space.test \ tap-bailout-and-logging.test \ tap-bailout-suppress-badexit.test \ tap-bailout-suppress-later-diagnostic.test \ diff --git a/tests/tap-bailout-leading-space.test b/tests/tap-bailout-leading-space.test new file mode 100755 index 000000000..1615c093f --- /dev/null +++ b/tests/tap-bailout-leading-space.test @@ -0,0 +1,72 @@ +#! /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 . + +# Older versions of prove and TAP::Harness (e.g., 3.17) didn't recognize +# a "Bail out!" directive that was preceded by whitespace, but more modern +# versions (e.g., 3.23) do. So we leave this behaviour undefined for the +# perl implementation of the Automake TAP driver, but expect the latter, +# "more modern" behaviour in our awk TAP driver. + +am_parallel_tests=yes +am_tap_implementation=shell +. ./defs || Exit 1 + +. "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh" + +cat > a.test < b.test < c.test <> exp <stdout \ + && { cat stdout; Exit 1; } +cat stdout + +count_test_results total=5 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=3 + +LC_ALL=C sort exp > t +mv -f t exp + +# We need the sort below to account for parallel make usage. +grep ': [abcde]\.test' stdout \ + | sed "s/[ $tab]*#[ $tab]*SKIP.*//" \ + | LC_ALL=C sort > got + +cat exp +cat got +diff exp got + +: diff --git a/tests/tap-no-spurious.test b/tests/tap-no-spurious.test index bf3d7aefa..c2d5bc541 100755 --- a/tests/tap-no-spurious.test +++ b/tests/tap-no-spurious.test @@ -84,6 +84,8 @@ set -x # Reset shell xtraces. # The prove(1) utility doesn't bail out on these, so our driver # shouldn't either. +# See comments in `tap-bailout-leading-space.test' for an explanation +# of why we don't have a whitespace-prepended "Bail out!" line here. cat >> all.test <<'END' bailout bailout! @@ -93,7 +95,6 @@ Bailout Bailout! Bail out Bail out - Bail out! #Bail out! # Bail out! END