From ffa86f7fa92d7156fe2a9586cef86d0207971c8b Mon Sep 17 00:00:00 2001 From: Richie McColl Date: Tue, 21 Feb 2023 08:39:17 +0000 Subject: [PATCH] test_runner: emit test-only diagnostic warning PR-URL: https://github.com/nodejs/node/pull/46540 Fixes: https://github.com/nodejs/node/issues/46448 Reviewed-By: Colin Ihrig Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- lib/internal/test_runner/test.js | 6 ++++++ test/message/test_runner_output.out | 3 +++ test/message/test_runner_output_cli.out | 3 +++ test/message/test_runner_output_spec_reporter.out | 3 +++ 4 files changed, 15 insertions(+) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index a2391047138bd9..ffbf2d257aed62 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -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() { diff --git a/test/message/test_runner_output.out b/test/message/test_runner_output.out index 15d2009816a961..1a165c33264e32 100644 --- a/test/message/test_runner_output.out +++ b/test/message/test_runner_output.out @@ -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 --- @@ -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 --- diff --git a/test/message/test_runner_output_cli.out b/test/message/test_runner_output_cli.out index a76b37a77ce187..c351b1fa26fc83 100644 --- a/test/message/test_runner_output_cli.out +++ b/test/message/test_runner_output_cli.out @@ -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 --- @@ -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 --- diff --git a/test/message/test_runner_output_spec_reporter.out b/test/message/test_runner_output_spec_reporter.out index 88ce796a783eeb..591dc9a76d64d0 100644 --- a/test/message/test_runner_output_spec_reporter.out +++ b/test/message/test_runner_output_spec_reporter.out @@ -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