Skip to content

Commit

Permalink
test: fix tap parser fails if a test logs a number
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit-30 committed Jan 8, 2023
1 parent 6766172 commit dba8a16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/internal/test_runner/tap_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,16 @@ class TapParser extends Transform {
}

const planEnd = this.#next();
if (planEnd?.kind !== TokenKind.NUMERIC) {
if (!planEnd || planEnd.kind !== TokenKind.NUMERIC) {
this.#error('Expected a plan end count');
const node = {
kind: TokenKind.UNKNOWN,
node: {
value: this.#currentChunkAsString,
},
};

return node;
}

const plan = {
Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-runner-tap-parser-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ const cases = [
},
],
},
{
input: '123',
expected: [
{
kind: 'Unknown',
node: { value: '123' },
nesting: 0,
lexeme: '123',
},
],
},
{
input: '# 123',
expected: [
{
kind: 'Comment',
node: { comment: '123' },
nesting: 0,
lexeme: '# 123',
},
],
},
{
input: 'invalid tap',
expected: [
Expand Down

0 comments on commit dba8a16

Please sign in to comment.