From: Ramsay Jones <ramsay@ramsay1•demon.co.uk>
To: Jonathan Nieder <jrnieder@gmail•com>
Cc: Junio C Hamano <gitster@pobox•com>,
GIT Mailing-list <git@vger•kernel.org>
Subject: [RFC/PATCH] t3300-*.sh: Fix a TAP parse error
Date: Sat, 21 Jul 2012 18:46:57 +0100 [thread overview]
Message-ID: <500AEB11.4050006@ramsay1.demon.co.uk> (raw)
At present, running the t3300-*.sh test on cygwin looks like:
$ cd t
$ ./t3300-funny-names.sh
ok 1 - setup
# passed all 1 test(s)
1..1 # SKIP Your filesystem does not allow tabs in filenames
$
Unfortunately, this is not valid TAP output, which prove notes
as follows:
$ prove --exec sh t3300-funny-names.sh
t3300-funny-names.sh .. All 1 subtests passed
Test Summary Report
-------------------
t3300-funny-names.sh (Wstat: 0 Tests: 1 Failed: 0)
Parse errors: No plan found in TAP output
Files=1, Tests=1, 2 wallclock secs ( 0.05 usr 0.00 sys + \
0.90 cusr 0.49 csys = 1.43 CPU)
Result: FAIL
$
This is due to the 'trailing_plan' having a 'skip_directive'
attached to it. This is not allowed by the TAP grammar, which
only allows a 'leading_plan' to be followed by an optional
'skip_directive'. (see perldoc TAP::Parser::Grammar).
A trailing_plan is one that appears in the TAP output after one or
more test status lines (that start 'not '? 'ok ' ...), whereas a
leading_plan must appear before all test status lines (if any).
In practice, this means that the test script cannot contain a use
of the 'skip all' facility:
skip_all='Some reason to skip *all* tests in this file'
test_done
after having already executed one or more tests with (for example)
'test_expect_success'. Unfortunately, this is exactly what this
test script is doing. The first 'setup' test is actually used to
determine if the test prerequisite is satisfied by the filesystem
(ie does it allow tabs in filenames?).
In order to fix the parse errors, place the code to determine the
test prerequisite at the top level of the script, rather than as
a parameter to test_expect_success. This allows us to correctly
use 'skip_all', thus:
$ ./t3300-funny-names.sh
# passed all 0 test(s)
1..0 # SKIP Your filesystem does not allow tabs in filenames
$
$ prove --exec sh t3300-funny-names.sh
t3300-funny-names.sh .. skipped: Your filesystem does not \
allow tabs in filenames
Files=1, Tests=0, 2 wallclock secs ( 0.02 usr 0.03 sys + \
0.84 cusr 0.41 csys = 1.29 CPU)
Result: NOTESTS
$
Signed-off-by: Ramsay Jones <ramsay@ramsay1•demon.co.uk>
---
Hi Jonathan,
This is an RFC because I suspect some people may prefer the much
simpler patch:
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 1f35e55..2a64385 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -34,7 +34,7 @@ test_expect_success 'setup' '
if ! test_have_prereq TABS_IN_FILENAMES
then
# since FAT/NTFS does not allow tabs in filenames, skip this test
- skip_all='Your filesystem does not allow tabs in filenames'
+ say '# SKIP Your filesystem does not allow tabs in filenames'
test_done
fi
... the output of which looks like:
$ cd t
$ ./t3300-funny-names.sh
ok 1 - setup
# SKIP Your filesystem does not allow tabs in filenames
# passed all 1 test(s)
1..1
$
$ prove --exec sh t3300-funny-names.sh
t3300-funny-names.sh .. ok
All tests successful.
Files=1, Tests=1, 1 wallclock secs ( 0.03 usr 0.01 sys + \
0.85 cusr 0.34 csys = 1.24 CPU)
Result: PASS
$
Needless to say, I much prefer the patch below. :-D
ATB,
Ramsay Jones
t/t3300-funny-names.sh | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 1f35e55..c51674a 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -15,28 +15,20 @@ p0='no-funny'
p1='tabs ," (dq) and spaces'
p2='just space'
-test_expect_success 'setup' '
- cat >"$p0" <<-\EOF &&
- 1. A quick brown fox jumps over the lazy cat, oops dog.
- 2. A quick brown fox jumps over the lazy cat, oops dog.
- 3. A quick brown fox jumps over the lazy cat, oops dog.
- EOF
-
- { cat "$p0" >"$p1" || :; } &&
- { echo "Foo Bar Baz" >"$p2" || :; } &&
+cat >"$p0" <<\EOF
+1. A quick brown fox jumps over the lazy cat, oops dog.
+2. A quick brown fox jumps over the lazy cat, oops dog.
+3. A quick brown fox jumps over the lazy cat, oops dog.
+EOF
- if test -f "$p1" && cmp "$p0" "$p1"
- then
- test_set_prereq TABS_IN_FILENAMES
- fi
-'
+cat 2>/dev/null >"$p1" "$p0"
+echo 'Foo Bar Baz' >"$p2"
-if ! test_have_prereq TABS_IN_FILENAMES
-then
+test -f "$p1" && cmp "$p0" "$p1" || {
# since FAT/NTFS does not allow tabs in filenames, skip this test
skip_all='Your filesystem does not allow tabs in filenames'
test_done
-fi
+}
test_expect_success 'setup: populate index and tree' '
git update-index --add "$p0" "$p2" &&
--
1.7.11.2
next reply other threads:[~2012-07-21 17:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-21 17:46 Ramsay Jones [this message]
2012-07-21 18:20 ` [RFC/PATCH] t3300-*.sh: Fix a TAP parse error Jonathan Nieder
2012-07-24 18:34 ` Ramsay Jones
2012-07-24 19:21 ` Jonathan Nieder
2012-07-25 18:36 ` Ramsay Jones
2012-07-24 19:57 ` Junio C Hamano
2012-07-25 19:07 ` Ramsay Jones
2012-07-25 20:51 ` Jonathan Nieder
2012-07-25 22:08 ` Junio C Hamano
2012-07-28 18:12 ` Ramsay Jones
2012-07-28 18:03 ` Ramsay Jones
2012-08-16 23:40 ` Junio C Hamano
2012-08-19 17:57 ` Ramsay Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=500AEB11.4050006@ramsay1.demon.co.uk \
--to=ramsay@ramsay1$(echo .)demon.co.uk \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=jrnieder@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox