From e651e18c097fb936aa3dc80ae80dda4ff79e77c4 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 28 Mar 2022 20:36:14 -0400 Subject: [PATCH] test_runner: support 'only' tests This commit introduces a CLI flag and test runner functionality to support running a subset of tests that are indicated by an 'only' option passed to the test. --- doc/api/cli.md | 10 +++ doc/api/test.md | 56 +++++++++++++ doc/node.1 | 4 + lib/internal/test_runner/test.js | 33 +++++--- src/node_options.cc | 4 + src/node_options.h | 1 + test/message/test_runner_only_tests.js | 48 +++++++++++ test/message/test_runner_only_tests.out | 102 ++++++++++++++++++++++++ test/message/test_runner_output.js | 10 +++ test/message/test_runner_output.out | 29 ++++++- 10 files changed, 283 insertions(+), 14 deletions(-) create mode 100644 test/message/test_runner_only_tests.js create mode 100644 test/message/test_runner_only_tests.out diff --git a/doc/api/cli.md b/doc/api/cli.md index cec177f0410c8e..92acc87e648a34 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1052,6 +1052,15 @@ minimum allocation from the secure heap. The minimum value is `2`. The maximum value is the lesser of `--secure-heap` or `2147483647`. The value given must be a power of two. +### `--test-only` + + + +Configures the test runner to only execute top level tests that have the `only` +option set. + ### `--throw-deprecation` + +* `shouldRunOnlyTests` {boolean} Whether or not to run `only` tests. + +If `shouldRunOnlyTests` is truthy, the test context will only run tests that +have the `only` option set. Otherwise, all tests are run. If Node.js was not +started with the [`--test-only`][] command-line option, this function is a +no-op. + ### `context.skip([message])`