{"thread":{"id":"31406","subject":"[PATCH 1/6] t3300-*.sh: Fix a TAP parse error","startedAt":"2012-09-01T18:08:42Z","lastAt":"2012-09-01T18:08:42Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"198199","messageId":"50424F2A.3080809@ramsay1.demon.co.uk","threadId":"31406","inReplyTo":null,"subject":"[PATCH 1/6] t3300-*.sh: Fix a TAP parse error","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-09-01T18:08:42Z","receivedAt":"2012-09-01T18:08:42Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nAt present, running the t3300-*.sh test on cygwin looks like:\n\n    $ cd t\n    $ ./t3300-funny-names.sh\n    ok 1 - setup\n    # passed all 1 test(s)\n    1..1 # SKIP Your filesystem does not allow tabs in filenames\n    $\n\nUnfortunately, this is not valid TAP output, which prove notes\nas follows:\n\n    $ prove --exec sh t3300-funny-names.sh\n    t3300-funny-names.sh .. All 1 subtests passed\n\n    Test Summary Report\n    -------------------\n    t3300-funny-names.sh (Wstat: 0 Tests: 1 Failed: 0)\n      Parse errors: No plan found in TAP output\n    Files=1, Tests=1,  2 wallclock secs ( 0.05 usr  0.00 sys +  \\\n        0.90 cusr  0.49 csys =  1.43 CPU)\n    Result: FAIL\n    $\n\nThis is due to the 'trailing_plan' having a 'skip_directive'\nattached to it. This is not allowed by the TAP grammar, which\nonly allows a 'leading_plan' to be followed by an optional\n'skip_directive'. (see perldoc TAP::Parser::Grammar).\n\nA trailing_plan is one that appears in the TAP output after one or\nmore test status lines (that start 'not '? 'ok ' ...), whereas a\nleading_plan must appear before all test status lines (if any).\n\nIn practice, this means that the test script cannot contain a use\nof the 'skip all' facility:\n\n    skip_all='Some reason to skip *all* tests in this file'\n    test_done\n\nafter having already executed one or more tests with (for example)\n'test_expect_success'. Unfortunately, this is exactly what this\ntest script is doing. The first 'setup' test is actually used to\ndetermine if the test prerequisite is satisfied by the filesystem\n(ie does it allow tabs in filenames?).\n\nIn order to fix the parse errors, place the code to determine the\ntest prerequisite at the top level of the script, prior to the\nfirst test, rather than as a parameter to test_expect_success.\nThis allows us to correctly use 'skip_all', thus:\n\n    $ ./t3300-funny-names.sh\n    # passed all 0 test(s)\n    1..0 # SKIP Your filesystem does not allow tabs in filenames\n    $\n\n    $ prove --exec sh t3300-funny-names.sh\n    t3300-funny-names.sh .. skipped: Your filesystem does not \\\n        allow tabs in filenames\n    Files=1, Tests=0,  2 wallclock secs ( 0.02 usr  0.03 sys +  \\\n        0.84 cusr  0.41 csys =  1.29 CPU)\n    Result: NOTESTS\n    $\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n t/t3300-funny-names.sh | 24 +++++++++++-------------\n 1 file changed, 11 insertions(+), 13 deletions(-)\n\ndiff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh\nindex 1f35e55..7480d6e 100755\n--- a/t/t3300-funny-names.sh\n+++ b/t/t3300-funny-names.sh\n@@ -11,6 +11,16 @@ tree, index, and tree objects.\n \n . ./test-lib.sh\n \n+HT='\t'\n+\n+echo 2>/dev/null > \"Name with an${HT}HT\"\n+if ! test -f \"Name with an${HT}HT\"\n+then\n+\t# since FAT/NTFS does not allow tabs in filenames, skip this test\n+\tskip_all='Your filesystem does not allow tabs in filenames'\n+\ttest_done\n+fi\n+\n p0='no-funny'\n p1='tabs\t,\" (dq) and spaces'\n p2='just space'\n@@ -23,21 +33,9 @@ test_expect_success 'setup' '\n \tEOF\n \n \t{ cat \"$p0\" >\"$p1\" || :; } &&\n-\t{ echo \"Foo Bar Baz\" >\"$p2\" || :; } &&\n-\n-\tif test -f \"$p1\" && cmp \"$p0\" \"$p1\"\n-\tthen\n-\t\ttest_set_prereq TABS_IN_FILENAMES\n-\tfi\n+\t{ echo \"Foo Bar Baz\" >\"$p2\" || :; }\n '\n \n-if ! test_have_prereq TABS_IN_FILENAMES\n-then\n-\t# since FAT/NTFS does not allow tabs in filenames, skip this test\n-\tskip_all='Your filesystem does not allow tabs in filenames'\n-\ttest_done\n-fi\n-\n test_expect_success 'setup: populate index and tree' '\n \tgit update-index --add \"$p0\" \"$p2\" &&\n \tt0=$(git write-tree)\n-- \n1.7.12\n"}]}