Skip to content

Commit e7e9868

Browse files
committed
test_runner: fix spec skip detection
1 parent 57508fb commit e7e9868

File tree

7 files changed

+585
-20
lines changed

7 files changed

+585
-20
lines changed

lib/internal/test_runner/tap_parser.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,12 +753,9 @@ class TapParser extends Transform {
753753
}
754754
}
755755

756-
const reason = StringPrototypeTrim(this.#readNextLiterals());
757-
if (todoOrSkipToken) {
758-
if (reason) {
759-
test.reason = reason;
760-
}
761-
756+
if (todoOrSkipToken === 'todo' || todoOrSkipToken === 'skip') {
757+
const reason = StringPrototypeTrim(this.#readNextLiterals());
758+
test.reason = reason || true;
762759
test.status.todo = todoOrSkipToken === 'todo';
763760
test.status.skip = todoOrSkipToken === 'skip';
764761
}

test/fixtures/test-runner/output/spec_reporter.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
test with a name and options provided (*ms) # SKIP
151151
functionAndOptions (*ms) # SKIP
152152
escaped description \ # \#\
153-
 (*ms)
153+
 (*ms)
154154
escaped skip message (*ms) # SKIP
155155
escaped todo message (*ms)
156156
escaped diagnostic (*ms)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Flags: --no-warnings
2+
'use strict';
3+
require('../../../common');
4+
const fixtures = require('../../../common/fixtures');
5+
const spawn = require('node:child_process').spawn;
6+
7+
const child = spawn(process.execPath,
8+
['--no-warnings', '--test', '--test-reporter', 'spec', fixtures.path('test-runner/output/output.js')],
9+
{ stdio: 'pipe' });
10+
// eslint-disable-next-line no-control-regex
11+
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
12+
child.stderr.pipe(process.stderr);

0 commit comments

Comments
 (0)