From 6a2fd8f004efb1215d2bc6ac6fe97fc0efb1a054 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Mon, 15 Aug 2022 12:12:11 +0300 Subject: [PATCH] test_runner: support programmatically running `--test` --- doc/api/test.md | 23 +++++ lib/internal/main/test_runner.js | 140 +------------------------ lib/internal/test_runner/harness.js | 12 ++- lib/internal/test_runner/runner.js | 154 ++++++++++++++++++++++++++++ lib/internal/test_runner/test.js | 2 +- lib/test.js | 10 +- 6 files changed, 192 insertions(+), 149 deletions(-) create mode 100644 lib/internal/test_runner/runner.js diff --git a/doc/api/test.md b/doc/api/test.md index 551259d314bb70..030f39aed12a4f 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -316,6 +316,29 @@ Otherwise, the test is considered to be a failure. Test files must be executable by Node.js, but are not required to use the `node:test` module internally. +## `runFiles([options])` + + + +* `options` {Object} Configuration options for running test files. The following + properties are supported: + * `concurrency` {number|boolean} If a number is provided, + then that many files would run in parallel. + If truthy, it would run (number of cpu cores - 1) + files in parallel. + If falsy, it would only run one file at a time. + If unspecified, subtests inherit this value from their parent. + **Default:** `true`. + * `files`: {Array} An array containing the list of files to run. + **Default** matching files from [test runner execution model][]. + * `signal` {AbortSignal} Allows aborting an in-progress test file. + * `timeout` {number} A number of milliseconds the test file will fail after. + If unspecified, subtests inherit this value from their parent. + **Default:** `Infinity`. +* Returns: {Promise} Resolved with `undefined` once all test files complete. + ## `test([name][, options][, fn])`