Skip to content

Commit

Permalink
test_runner: emit test-only diagnostic warning
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemccoll committed Feb 7, 2023
1 parent 8e6e215 commit 3ee8044
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ class Test extends AsyncResource {
};
this.waitingOn = 0;
this.finished = false;

if (!testOnlyFlag && only) {
const warning =
"'only' does not work when node is started" +
' without the --test-only command-line option';
this.diagnostic(warning);
}
}

hasConcurrency() {
Expand Down
9 changes: 9 additions & 0 deletions test/message/test_runner_only_warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';
require('../common');
const { test } = require('node:test');

test('only = true without --test-only flag', { only: true }, () => {});

test('subtest only = true without --test-only flag', (t) => {
t.test('this subtest is run', { only: true });
});
27 changes: 27 additions & 0 deletions test/message/test_runner_only_warning.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
TAP version 13
# Subtest: only = true without --test-only flag
ok 1 - only = true without --test-only flag
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
# Subtest: subtest only = true without --test-only flag
# Subtest: this subtest is run
ok 1 - this subtest is run
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
1..1
ok 2 - subtest only = true without --test-only flag
---
duration_ms: *
...
1..2
# tests 2
# pass 2
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
2 changes: 2 additions & 0 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ ok 52 - callback async throw after done
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
# Subtest: running subtest 4
ok 4 - running subtest 4
---
Expand All @@ -490,6 +491,7 @@ ok 53 - only is set but not in only mode
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
# Subtest: custom inspect symbol fail
not ok 54 - custom inspect symbol fail
---
Expand Down
2 changes: 2 additions & 0 deletions test/message/test_runner_output_cli.out
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ TAP version 13
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
# Subtest: running subtest 4
ok 4 - running subtest 4
---
Expand All @@ -491,6 +492,7 @@ TAP version 13
---
duration_ms: *
...
# 'only' does not work when node is started without the --test-only command-line option
# Subtest: custom inspect symbol fail
not ok 54 - custom inspect symbol fail
---
Expand Down
2 changes: 2 additions & 0 deletions test/message/test_runner_output_spec_reporter.out
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@
running subtest 1 (*ms)
running subtest 2 (*ms)
running subtest 3 (*ms)
'only' does not work when node is started without the --test-only command-line option
running subtest 4 (*ms)
only is set but not in only mode (*ms)
'only' does not work when node is started without the --test-only command-line option

custom inspect symbol fail (*ms)
customized
Expand Down

0 comments on commit 3ee8044

Please sign in to comment.