Skip to content

Commit 3ee8044

Browse files
committed
test_runner: emit test-only diagnostic warning
1 parent 8e6e215 commit 3ee8044

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

lib/internal/test_runner/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ class Test extends AsyncResource {
288288
};
289289
this.waitingOn = 0;
290290
this.finished = false;
291+
292+
if (!testOnlyFlag && only) {
293+
const warning =
294+
"'only' does not work when node is started" +
295+
' without the --test-only command-line option';
296+
this.diagnostic(warning);
297+
}
291298
}
292299

293300
hasConcurrency() {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
require('../common');
3+
const { test } = require('node:test');
4+
5+
test('only = true without --test-only flag', { only: true }, () => {});
6+
7+
test('subtest only = true without --test-only flag', (t) => {
8+
t.test('this subtest is run', { only: true });
9+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
TAP version 13
2+
# Subtest: only = true without --test-only flag
3+
ok 1 - only = true without --test-only flag
4+
---
5+
duration_ms: *
6+
...
7+
# 'only' does not work when node is started without the --test-only command-line option
8+
# Subtest: subtest only = true without --test-only flag
9+
# Subtest: this subtest is run
10+
ok 1 - this subtest is run
11+
---
12+
duration_ms: *
13+
...
14+
# 'only' does not work when node is started without the --test-only command-line option
15+
1..1
16+
ok 2 - subtest only = true without --test-only flag
17+
---
18+
duration_ms: *
19+
...
20+
1..2
21+
# tests 2
22+
# pass 2
23+
# fail 0
24+
# cancelled 0
25+
# skipped 0
26+
# todo 0
27+
# duration_ms *

test/message/test_runner_output.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ ok 52 - callback async throw after done
480480
---
481481
duration_ms: *
482482
...
483+
# 'only' does not work when node is started without the --test-only command-line option
483484
# Subtest: running subtest 4
484485
ok 4 - running subtest 4
485486
---
@@ -490,6 +491,7 @@ ok 53 - only is set but not in only mode
490491
---
491492
duration_ms: *
492493
...
494+
# 'only' does not work when node is started without the --test-only command-line option
493495
# Subtest: custom inspect symbol fail
494496
not ok 54 - custom inspect symbol fail
495497
---

test/message/test_runner_output_cli.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ TAP version 13
481481
---
482482
duration_ms: *
483483
...
484+
# 'only' does not work when node is started without the --test-only command-line option
484485
# Subtest: running subtest 4
485486
ok 4 - running subtest 4
486487
---
@@ -491,6 +492,7 @@ TAP version 13
491492
---
492493
duration_ms: *
493494
...
495+
# 'only' does not work when node is started without the --test-only command-line option
494496
# Subtest: custom inspect symbol fail
495497
not ok 54 - custom inspect symbol fail
496498
---

test/message/test_runner_output_spec_reporter.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@
200200
running subtest 1 (*ms)
201201
running subtest 2 (*ms)
202202
running subtest 3 (*ms)
203+
'only' does not work when node is started without the --test-only command-line option
203204
running subtest 4 (*ms)
204205
only is set but not in only mode (*ms)
206+
'only' does not work when node is started without the --test-only command-line option
205207

206208
custom inspect symbol fail (*ms)
207209
customized

0 commit comments

Comments
 (0)