Skip to content

Commit 514fd0b

Browse files
committed
test_runner: emit test-only diagnostic warning
1 parent 5092346 commit 514fd0b

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

lib/internal/test_runner/test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ class Test extends AsyncResource {
247247
}
248248

249249
if (testOnlyFlag && !this.only) {
250-
skip = '\'only\' option not set';
250+
skip = "'only' option not set";
251+
} else if (!testOnlyFlag && (only || this.runOnlySubtests)) {
252+
this.emitOnlyWarning = true;
251253
}
252254

253255
if (skip) {
@@ -710,6 +712,13 @@ class Test extends AsyncResource {
710712
for (let i = 0; i < this.diagnostics.length; i++) {
711713
this.reporter.diagnostic(this.nesting, kFilename, this.diagnostics[i]);
712714
}
715+
716+
if (this.emitOnlyWarning) {
717+
const warning =
718+
"to use 'only' or 'runOnly' in the test runner" +
719+
' run node with the --test-only command-line option.';
720+
this.reporter.diagnostic(this.nesting, kFilename, warning);
721+
}
713722
}
714723

715724
reportStarted() {

test/message/test_runner_output.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,13 @@ ok 52 - callback async throw after done
475475
---
476476
duration_ms: *
477477
...
478+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
478479
# Subtest: running subtest 3
479480
ok 3 - running subtest 3
480481
---
481482
duration_ms: *
482483
...
484+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
483485
# Subtest: running subtest 4
484486
ok 4 - running subtest 4
485487
---
@@ -490,6 +492,7 @@ ok 53 - only is set but not in only mode
490492
---
491493
duration_ms: *
492494
...
495+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
493496
# Subtest: custom inspect symbol fail
494497
not ok 54 - custom inspect symbol fail
495498
---

test/message/test_runner_output_cli.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,13 @@ TAP version 13
476476
---
477477
duration_ms: *
478478
...
479+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
479480
# Subtest: running subtest 3
480481
ok 3 - running subtest 3
481482
---
482483
duration_ms: *
483484
...
485+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
484486
# Subtest: running subtest 4
485487
ok 4 - running subtest 4
486488
---
@@ -491,6 +493,7 @@ TAP version 13
491493
---
492494
duration_ms: *
493495
...
496+
# to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
494497
# Subtest: custom inspect symbol fail
495498
not ok 54 - custom inspect symbol fail
496499
---

test/message/test_runner_output_spec_reporter.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,12 @@
199199
only is set but not in only mode
200200
running subtest 1 (*ms)
201201
running subtest 2 (*ms)
202+
to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
202203
running subtest 3 (*ms)
204+
to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
203205
running subtest 4 (*ms)
204206
only is set but not in only mode (*ms)
207+
to use 'only' or 'runOnly' in the test runner run node with the --test-only command-line option.
205208

206209
custom inspect symbol fail (*ms)
207210
customized

0 commit comments

Comments
 (0)