From d35cee2a6c394e13b81ebef29fe53eea4e2b533d Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 12 Aug 2011 10:49:05 +0200 Subject: [PATCH] tap: non-zero exit status after "Bail out!" should not be reported This new behaviour is more consistent with that of the `prove' utility. Also, experience with the use of TAP in the Automake's own test suite has shown that reporting non-zero exit status from a script after it has issued a "Bail out!" directive is mostly redundant, more introducing noise rather than conveying useful information. * lib/tap-driver (finish): Inline the part of it that was getting the script exit status ... (main): ... in here. * tests/tap-bailout-badexit.test: New test. * tests/Makefile.am (tap_with_common_setup_tests): Update. --- ChangeLog | 15 ++++++++ lib/tap-driver | 8 ++--- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/tap-bailout-badexit.test | 65 ++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 4 deletions(-) create mode 100755 tests/tap-bailout-badexit.test diff --git a/ChangeLog b/ChangeLog index 4ea0ee763..9a1d6011e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-08-12 Stefano Lattarini + + tap: non-zero exit status after "Bail out!" should not be reported + This new behaviour is more consistent with that of the `prove' + utility. Also, experience with the use of TAP in the Automake's + own test suite has shown that reporting non-zero exit status from + a script after it has issued a "Bail out!" directive is mostly + redundant, more introducing noise rather than conveying useful + information. + * lib/tap-driver (finish): Inline the part of it that was getting + the script exit status ... + (main): ... in here. + * tests/tap-bailout-badexit.test: New test. + * tests/Makefile.am (tap_with_common_setup_tests): Update. + 2011-08-11 Stefano Lattarini tap: a "plan with SKIP" after test results is an error diff --git a/lib/tap-driver b/lib/tap-driver index a02557dbf..b7a8ffbe3 100755 --- a/lib/tap-driver +++ b/lib/tap-driver @@ -235,10 +235,6 @@ sub get_test_exit_message () sub finish () { - if (!$cfg{"ignore-exit"} and my $msg = get_test_exit_message) - { - testsuite_error $msg; - } write_test_results; close LOG or die "closing $log_file: $!\n"; exit 0; @@ -444,6 +440,10 @@ sub main (@) testsuite_error (sprintf "too %s tests run (expected %d, got %d)", $bad_amount, $planned, $run); } + if (!$cfg{"ignore-exit"} and my $msg = get_test_exit_message) + { + testsuite_error $msg; + } finish; } diff --git a/tests/Makefile.am b/tests/Makefile.am index ae76516c9..cf78cb649 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1144,6 +1144,7 @@ testsuite-summary-count-many.log: extract-testsuite-summary tap_with_common_setup_tests = \ tap-autonumber.test \ tap-bailout.test \ +tap-bailout-badexit.test \ tap-color.test \ tap-deps.test \ tap-diagnostic.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index d43abe98a..39d1da07c 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1384,6 +1384,7 @@ $(parallel_tests) tap_with_common_setup_tests = \ tap-autonumber.test \ tap-bailout.test \ +tap-bailout-badexit.test \ tap-color.test \ tap-deps.test \ tap-diagnostic.test \ diff --git a/tests/tap-bailout-badexit.test b/tests/tap-bailout-badexit.test new file mode 100755 index 000000000..059394c32 --- /dev/null +++ b/tests/tap-bailout-badexit.test @@ -0,0 +1,65 @@ +#! /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 . + +# Basic TAP test protocol support: +# - A "Bail out!" directive causes the driver to ignore the exit +# status of the test script. + +parallel_tests=yes +. ./defs || Exit 1 + +tests='exit.test exit127.test sighup.test sigterm.test' + +cat > Makefile.am < exit.test << 'END' +#!/bin/sh +echo 'Bail out!' +exit 1 +END + +cat > exit127.test << 'END' +#!/bin/sh +echo 'Bail out!' +exit 127 +END + +cat > sighup.test << 'END' +#!/bin/sh +echo 'Bail out!' +kill -1 $$ +END + +cat > sigterm.test << 'END' +#!/bin/sh +echo 'Bail out!' +kill -15 $$ +END + +chmod a+x $tests + +$MAKE check >stdout && { cat stdout; Exit 1; } +cat stdout + +count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=4 +for tst in $tests; do grep "^ERROR: $tst - Bail out!" stdout; done +$EGREP "ERROR: .*(exit.*status|terminat.*signal)" stdout && Exit 1 + +: -- 2.47.2