From d762a341280883931c8c9d29129450070ed02edc Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 31 Aug 2022 21:33:39 -0400 Subject: [PATCH] test_runner: add --test-name-pattern CLI flag This commit adds support for running tests that match a regular expression. Fixes: https://github.com/nodejs/node/issues/42984 --- doc/api/cli.md | 11 ++ doc/api/test.md | 37 ++++++ doc/node.1 | 4 + lib/internal/test_runner/test.js | 31 ++++- lib/internal/test_runner/utils.js | 23 +++- src/node_options.cc | 3 + src/node_options.h | 1 + test/message/test_runner_test_name_pattern.js | 47 ++++++++ .../message/test_runner_test_name_pattern.out | 107 ++++++++++++++++++ ...test_runner_test_name_pattern_with_only.js | 13 +++ ...est_runner_test_name_pattern_with_only.out | 40 +++++++ test/parallel/test-runner-string-to-regexp.js | 20 ++++ 12 files changed, 333 insertions(+), 4 deletions(-) create mode 100644 test/message/test_runner_test_name_pattern.js create mode 100644 test/message/test_runner_test_name_pattern.out create mode 100644 test/message/test_runner_test_name_pattern_with_only.js create mode 100644 test/message/test_runner_test_name_pattern_with_only.out create mode 100644 test/parallel/test-runner-string-to-regexp.js diff --git a/doc/api/cli.md b/doc/api/cli.md index d69086b0bf6f08..4b4a766854a338 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1187,6 +1187,16 @@ Starts the Node.js command line test runner. This flag cannot be combined with `--check`, `--eval`, `--interactive`, or the inspector. See the documentation on [running tests from the command line][] for more details. +### `--test-name-pattern` + + + +A regular expression that configures the test runner to only execute tests +whose name matches the provided pattern. See the documentation on +[filtering tests by name][] for more details. + ### `--test-only`