diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-12-27 11:45:59 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-12-27 18:30:00 +0100 |
commit | 2fa8a9e975ce30702c87bd827b61f6e59ad98678 (patch) | |
tree | 8c1d3d64374a2e1bbd7acd263fa0faa97eb7b3bf | |
parent | 58f034a3eebeaa1b16415fbb76e02fe378d6413f (diff) | |
download | automake-2fa8a9e975ce30702c87bd827b61f6e59ad98678.tar.gz |
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.
-rw-r--r-- | ChangeLog | 17 | ||||
-rwxr-xr-x | lib/tap-driver.sh | 10 | ||||
-rw-r--r-- | tests/list-of-tests.mk | 1 | ||||
-rwxr-xr-x | tests/tap-bailout-leading-space.test | 72 | ||||
-rwxr-xr-x | tests/tap-no-spurious.test | 3 |
5 files changed, 99 insertions, 4 deletions
@@ -1,5 +1,22 @@ 2011-12-27 Stefano Lattarini <stefano.lattarini@gmail.com> + 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 <stefano.lattarini@gmail.com> + tests: fix spurious failure of cond29.test * tests/cond29.test: Limit the amount of virtual memory available to the automake process to ~ 150 MB, rather than only ~ 20 MB, to 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 <bug-automake@gnu.org> or send patches to # <automake-patches@gnu.org>. -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 <http://www.gnu.org/licenses/>. + +# 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 <<END +1..1 +ok 1 + Bail out! +END + +cat > b.test <<END +1..1 +ok 1 # SKIP +${tab}Bail out! +END + +cat > c.test <<END +1..1 + ${tab} ${tab}${tab}Bail out! FUBAR! $tab +END + +cat >> exp <<END +PASS: a.test 1 +ERROR: a.test - Bail out! +SKIP: b.test 1 +ERROR: b.test - Bail out! +ERROR: c.test - Bail out! FUBAR! +END + +TESTS='a.test b.test c.test' $MAKE -e check >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 |