From 9bab5b7a4e5cf40cb90435ffb1b8a076e74de108 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 8 Mar 2024 18:47:15 -0500 Subject: [PATCH] test_runner: support forced exit This commit updates the test runner to allow a forced exit once all known tests have finished running. Fixes: https://github.com/nodejs/node/issues/49925 --- doc/api/cli.md | 9 +++++ doc/api/test.md | 6 ++++ doc/node.1 | 4 +++ lib/internal/test_runner/harness.js | 1 + lib/internal/test_runner/runner.js | 36 +++++++++++++++++-- lib/internal/test_runner/test.js | 23 ++++++++---- lib/internal/test_runner/utils.js | 2 ++ src/node_options.cc | 6 ++++ src/node_options.h | 1 + .../fixtures/test-runner/output/force_exit.js | 25 +++++++++++++ .../test-runner/output/force_exit.snapshot | 16 +++++++++ test/parallel/test-runner-output.mjs | 1 + test/parallel/test-runner-run.mjs | 18 ++++++++++ 13 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/test-runner/output/force_exit.js create mode 100644 test/fixtures/test-runner/output/force_exit.snapshot diff --git a/doc/api/cli.md b/doc/api/cli.md index df90e9ae306b45..7eabdf6a301776 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1866,6 +1866,15 @@ added: The maximum number of test files that the test runner CLI will execute concurrently. The default value is `os.availableParallelism() - 1`. +### `--test-force-exit` + + + +Configures the test runner to exit the process once all known tests have +finished executing even if the event loop would otherwise remain active. + ### `--test-name-pattern`