-
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TAP::Harness choking on single backslashes in descriptions
Currently, TAP::Harness assumes backslashes in test descriptions will always be either doubled, or followed by '#'. Since backslashing every slash produces altered descriptions, we made Test.pm6 only backslash '#' in descriptions[^1], but that broke the harness's expectations. Fix by changing the grammar for description token to accept single slashes too. Neither v12[^2], v13[^3], or v14 draft [^4] versions of TAP spec say anything about backslashes or whether they can escape '#' in test descriptions to prevent it from specifying a TAP directive. So the correctitude of this commit's behaviour is based on what Perl 5's is doing. P.S.: I couldn't figure out how to make TAP::Harness keep quiet and not produce any output, hence such a weird test included in this work. [1] b183cab [2] https://testanything.org/tap-specification.html [3] https://testanything.org/tap-version-13-specification.html [4] TestAnything/testanything.github.io#36
- Loading branch information
1 parent
4038c6c
commit b120ac4
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use v6; | ||
use lib <lib>; | ||
use Test; | ||
use TAP:auth<perl>; | ||
|
||
plan 8; | ||
|
||
constant $TEST_FILE | ||
= 't/06-tap-harness/test-files/01-desc-backslashes--1.TAP-TEST'; | ||
|
||
# stupid hack to avoid TAP::Harness's output from interfering with our tests | ||
# I can't find docs for it to know how to do this properly; so run it as | ||
# as a separate script, make it do tests, then test that output with like() | ||
given run :out, :err, $*EXECUTABLE, '-e', 「 | ||
use lib <lib>; | ||
use Test; | ||
use TAP:auth<perl>; | ||
plan 8; | ||
my $h = TAP::Harness.new; | ||
my $w = $h.run('」 ~ $TEST_FILE ~ 「').waiter; | ||
await $w; | ||
given $w.result { | ||
is .tests-planned, 12, 'HTEST1 planned'; | ||
is .passed, 12, 'HTEST2 passed'; | ||
is .failed, 0, 'HTEST3 failed'; | ||
is .errors, 0, 'HTEST4 errors'; | ||
is .skipped, 1, 'HTEST5 skipped'; | ||
is .todo, 0, 'HTEST6 todo'; | ||
is .todo-passed, 0, 'HTEST7 todo passed'; | ||
is .exit-failed, False, 'HTEST8 exit failed'; | ||
} | ||
」 { | ||
given .err.slurp-rest { when :so { diag "STDERR output was ```$_```" } } | ||
|
||
like $output, /^^ 'ok' \N+ 'HTEST1'/, 'planned'; | ||
like $output, /^^ 'ok' \N+ 'HTEST2'/, 'passed'; | ||
like $output, /^^ 'ok' \N+ 'HTEST3'/, 'failed'; | ||
like $output, /^^ 'ok' \N+ 'HTEST4'/, 'errors'; | ||
like $output, /^^ 'ok' \N+ 'HTEST5'/, 'skipped'; | ||
like $output, /^^ 'ok' \N+ 'HTEST6'/, 'todo'; | ||
like $output, /^^ 'ok' \N+ 'HTEST7'/, 'todo passed'; | ||
like $output, /^^ 'ok' \N+ 'HTEST8'/, '.exit-failed'; | ||
} |
17 changes: 17 additions & 0 deletions
17
t/06-tap-harness/test-files/01-desc-backslashes--1.TAP-TEST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env perl6 | ||
use v6; | ||
use Test; | ||
plan 12; | ||
|
||
ok 1, 'fake todo # TODO it is fake 1'; | ||
ok 1, 'fake todo \# TODO it is fake 2'; | ||
ok 1, 'fake todo \\# TODO it is fake 3'; | ||
ok 1, 'fake todo \\# TODO it is fake 4'; | ||
ok 1, 'fake todo \\\# TODO it is fake 5'; | ||
ok 1, 'fake todo \\\\# TODO it is fake 6'; | ||
ok 1, 'fake todo \\\\\# TODO it is fake 7'; | ||
ok 1, '\\'; | ||
ok 1, '\\\\'; | ||
ok 1, '\\\\\\'; | ||
ok 1, '\\\\\\\\'; | ||
ok 1, '\\\\\\\\\\'; |