Skip to content

Commit 46d9847

Browse files
Ramsay Jonesgitster
authored andcommitted
t3300-*.sh: Fix a TAP parse error
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, prior to the first test, 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 871e293 commit 46d9847

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

t/t3300-funny-names.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ tree, index, and tree objects.
1111

1212
. ./test-lib.sh
1313

14+
HT=' '
15+
16+
echo 2>/dev/null > "Name with an${HT}HT"
17+
if ! test -f "Name with an${HT}HT"
18+
then
19+
# since FAT/NTFS does not allow tabs in filenames, skip this test
20+
skip_all='Your filesystem does not allow tabs in filenames'
21+
test_done
22+
fi
23+
1424
p0='no-funny'
1525
p1='tabs ," (dq) and spaces'
1626
p2='just space'
@@ -23,21 +33,9 @@ test_expect_success 'setup' '
2333
EOF
2434
2535
{ cat "$p0" >"$p1" || :; } &&
26-
{ echo "Foo Bar Baz" >"$p2" || :; } &&
27-
28-
if test -f "$p1" && cmp "$p0" "$p1"
29-
then
30-
test_set_prereq TABS_IN_FILENAMES
31-
fi
36+
{ echo "Foo Bar Baz" >"$p2" || :; }
3237
'
3338

34-
if ! test_have_prereq TABS_IN_FILENAMES
35-
then
36-
# since FAT/NTFS does not allow tabs in filenames, skip this test
37-
skip_all='Your filesystem does not allow tabs in filenames'
38-
test_done
39-
fi
40-
4139
test_expect_success 'setup: populate index and tree' '
4240
git update-index --add "$p0" "$p2" &&
4341
t0=$(git write-tree)

0 commit comments

Comments
 (0)