From 84de97a61e5c0591a310b5b12cc2be34b6893b36 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Wed, 13 Mar 2024 06:49:15 -0400 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 PR-URL: https://github.com/nodejs/node/pull/52038 Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow Reviewed-By: Raz Luvaton Reviewed-By: Benjamin Gruenbaum --- 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 | 28 +++++++++++---- lib/internal/test_runner/utils.js | 2 ++ src/node_options.cc | 6 ++++ src/node_options.h | 1 + .../fixtures/test-runner/output/force_exit.js | 27 ++++++++++++++ .../test-runner/output/force_exit.snapshot | 16 +++++++++ .../test-runner/throws_sync_and_async.js | 10 ++++++ .../test-runner-force-exit-failure.js | 15 ++++++++ test/parallel/test-runner-output.mjs | 1 + test/parallel/test-runner-run.mjs | 18 ++++++++++ 15 files changed, 170 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 create mode 100644 test/fixtures/test-runner/throws_sync_and_async.js create mode 100644 test/parallel/test-runner-force-exit-failure.js diff --git a/doc/api/cli.md b/doc/api/cli.md index d7b514694595b0..b445f6b0e176f1 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1872,6 +1872,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`