Skip to content

Commit

Permalink
test_runner: emit test-only diagnostic warning
Browse files Browse the repository at this point in the history
PR-URL: nodejs#46540
Fixes: nodejs#46448
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
richiemccoll authored and MoLow committed Feb 25, 2023
1 parent bb8cdf6 commit 0c8f40d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ class Test extends AsyncResource {
};
this.waitingOn = 0;
this.finished = false;

if (!testOnlyFlag && (only || this.runOnlySubtests)) {
const warning =
"'only' and 'runOnly' require the --test-only command-line option.";
this.diagnostic(warning);
}
}

hasConcurrency() {
Expand Down
3 changes: 3 additions & 0 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,13 @@ ok 52 - callback async throw after done
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: running subtest 3
ok 3 - running subtest 3
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: running subtest 4
ok 4 - running subtest 4
---
Expand All @@ -490,6 +492,7 @@ ok 53 - only is set but not in only mode
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: custom inspect symbol fail
not ok 54 - custom inspect symbol fail
---
Expand Down
3 changes: 3 additions & 0 deletions test/message/test_runner_output_cli.out
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,13 @@ ok 52 - callback async throw after done
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: running subtest 3
ok 3 - running subtest 3
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: running subtest 4
ok 4 - running subtest 4
---
Expand All @@ -490,6 +492,7 @@ ok 53 - only is set but not in only mode
---
duration_ms: *
...
# 'only' and 'runOnly' require the --test-only command-line option.
# Subtest: custom inspect symbol fail
not ok 54 - custom inspect symbol fail
---
Expand Down
3 changes: 3 additions & 0 deletions test/message/test_runner_output_spec_reporter.out
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@
only is set but not in only mode
running subtest 1 (*ms)
running subtest 2 (*ms)
'only' and 'runOnly' require the --test-only command-line option.
running subtest 3 (*ms)
'only' and 'runOnly' require the --test-only command-line option.
running subtest 4 (*ms)
only is set but not in only mode (*ms)
'only' and 'runOnly' require the --test-only command-line option.

custom inspect symbol fail (*ms)
customized
Expand Down

0 comments on commit 0c8f40d

Please sign in to comment.