Files
node/lib/internal/main/test_runner.js
T
Colin Ihrig f09063752b test_runner: consolidate option parsing
This commit consolidates all option parsing for the test runner
in the parseCommandLine() internal helper function. The exception
is a couple of temporary flags used for feature gating which
will eventually become no-ops. This consolidation is prep work
for supporting running test files in the test runner process.

PR-URL: https://github.com/nodejs/node/pull/53849
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2024-07-16 21:05:46 +00:00

52 lines
1.3 KiB
JavaScript

'use strict';
const {
prepareMainThreadExecution,
markBootstrapComplete,
} = require('internal/process/pre_execution');
const { isUsingInspector } = require('internal/util/inspector');
const { run } = require('internal/test_runner/runner');
const {
parseCommandLine,
setupTestReporters,
} = require('internal/test_runner/utils');
const { exitCodes: { kGenericUserError } } = internalBinding('errors');
let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
debug = fn;
});
prepareMainThreadExecution(false);
markBootstrapComplete();
const {
perFileTimeout,
runnerConcurrency,
shard,
watchMode,
} = parseCommandLine();
let concurrency = runnerConcurrency;
let inspectPort;
if (isUsingInspector()) {
process.emitWarning('Using the inspector with --test forces running at a concurrency of 1. ' +
'Use the inspectPort option to run with concurrency');
concurrency = 1;
inspectPort = process.debugPort;
}
const options = {
concurrency,
inspectPort,
watch: watchMode,
setup: setupTestReporters,
timeout: perFileTimeout,
shard,
};
debug('test runner configuration:', options);
run(options).on('test:fail', (data) => {
if (data.todo === undefined || data.todo === false) {
process.exitCode = kGenericUserError;
}
});