From 78a860ae58bf332e9a8562233703a4eb4724f0db Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Fri, 15 Apr 2022 13:37:28 -0400 Subject: [PATCH] test_runner: add initial CLI runner This commit introduces an initial version of a CLI-based test runner. PR-URL: https://github.com/nodejs/node/pull/42658 Reviewed-By: Antoine du Hamel --- doc/api/cli.md | 11 ++ doc/api/test.md | 63 +++++++ doc/node.1 | 3 + lib/internal/errors.js | 20 +- lib/internal/main/test_runner.js | 157 ++++++++++++++++ lib/internal/test_runner/tap_stream.js | 173 ++++++++++-------- lib/internal/test_runner/test.js | 31 +++- lib/internal/test_runner/utils.js | 15 ++ src/node.cc | 4 + src/node_options.cc | 21 +++ src/node_options.h | 1 + test/fixtures/test-runner/index.js | 2 + test/fixtures/test-runner/index.test.js | 4 + .../test-runner/node_modules/test-nm.js | 2 + test/fixtures/test-runner/random.test.mjs | 5 + .../test-runner/subdir/subdir_test.js | 0 test/fixtures/test-runner/test/random.cjs | 4 + test/message/test_runner_no_refs.out | 8 +- test/message/test_runner_output.js | 23 +++ test/message/test_runner_output.out | 93 ++++++---- .../test_runner_unresolved_promise.out | 8 +- test/parallel/test-runner-cli.js | 107 +++++++++++ test/parallel/test-runner-test-filter.js | 42 +++++ 23 files changed, 669 insertions(+), 128 deletions(-) create mode 100644 lib/internal/main/test_runner.js create mode 100644 lib/internal/test_runner/utils.js create mode 100644 test/fixtures/test-runner/index.js create mode 100644 test/fixtures/test-runner/index.test.js create mode 100644 test/fixtures/test-runner/node_modules/test-nm.js create mode 100644 test/fixtures/test-runner/random.test.mjs create mode 100644 test/fixtures/test-runner/subdir/subdir_test.js create mode 100644 test/fixtures/test-runner/test/random.cjs create mode 100644 test/parallel/test-runner-cli.js create mode 100644 test/parallel/test-runner-test-filter.js diff --git a/doc/api/cli.md b/doc/api/cli.md index a146e255512892..047ed24697a10d 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1052,6 +1052,16 @@ 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` + + + +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-only`