Skip to content

Commit

Permalink
test_runner: tap parser
Browse files Browse the repository at this point in the history
parse dashes in comments
  • Loading branch information
manekinekko committed Jun 21, 2022
1 parent 5df0d8e commit 12fc364
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/internal/test_runner/tap_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class TapParser {
[
TokenKind.LITERAL,
TokenKind.NUMERIC,
TokenKind.DASH,
TokenKind.WHITESPACE,
TokenKind.ESCAPE,
].includes(nextToken.type)
Expand All @@ -117,7 +118,7 @@ class TapParser {
nextToken = this.peek(false);
}

return literals.join('');
return literals.join('').trim();
}

// split all tokens by EOL: [[token1, token2, ...], [token1, token2, ...]]
Expand Down
46 changes: 46 additions & 0 deletions lib/internal/test_runner/tap_parser_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ not ok 2 - bar.tap
Bail out! Error: Couldn't connect to database.
`);

// more examples from https://testanything.org/tap-version-14-specification.html#examples

TAP(`
TAP version 14
1..6
Expand All @@ -295,3 +297,47 @@ ok 4 - Get possible places to put the Tile
ok 5 - Placing the tile produces no error
ok 6 - Board size is 1
`);

TAP(`
TAP version 14
ok 1 - retrieving servers from the database
# need to ping 6 servers
ok 2 - pinged diamond
ok 3 - pinged ruby
not ok 4 - pinged saphire
---
message: 'hostname "saphire" unknown'
severity: fail
...
ok 5 - pinged onyx
not ok 6 - pinged quartz
---
message: 'timeout'
severity: fail
...
ok 7 - pinged gold
1..7
`)

TAP(`
TAP version 14
1..573
not ok 1 - database handle
Bail out! Couldn't connect to database.
`);

TAP(`
TAP version 14
1..5
ok 1 - approved operating system
# $^0 is solaris
ok 2 - # SKIP no /sys directory
ok 3 - # SKIP no /sys directory
ok 4 - # SKIP no /sys directory
ok 5 - # SKIP no /sys directory
`);

TAP(`
TAP version 14
1..0 # skip because English-to-French translator isn't installed
`);

0 comments on commit 12fc364

Please sign in to comment.