mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test_runner: use run() argument names in parseCommandLine()
This commit updates parseCommandLine() to use the names supported by run(). This removes some unnecessary renaming code, and allows node:test and run() to more easily share code. PR-URL: https://github.com/nodejs/node/pull/54353 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
e020dd8610
commit
1abdd66da3
3 files changed
+24
-38
No files matched your search
@@ -22,32 +22,18 @@ let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
|
||||
prepareMainThreadExecution(false);
|
||||
markBootstrapComplete();
|
||||
|
||||
const {
|
||||
perFileTimeout,
|
||||
runnerConcurrency,
|
||||
shard,
|
||||
watchMode,
|
||||
} = parseCommandLine();
|
||||
|
||||
let concurrency = runnerConcurrency;
|
||||
let inspectPort;
|
||||
const options = parseCommandLine();
|
||||
|
||||
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;
|
||||
options.concurrency = 1;
|
||||
options.inspectPort = process.debugPort;
|
||||
}
|
||||
|
||||
const options = {
|
||||
concurrency,
|
||||
inspectPort,
|
||||
watch: watchMode,
|
||||
setup: setupTestReporters,
|
||||
timeout: perFileTimeout,
|
||||
shard,
|
||||
globPatterns: ArrayPrototypeSlice(process.argv, 1),
|
||||
};
|
||||
options.setup = setupTestReporters;
|
||||
options.globPatterns = ArrayPrototypeSlice(process.argv, 1);
|
||||
|
||||
debug('test runner configuration:', options);
|
||||
run(options).on('test:fail', (data) => {
|
||||
if (data.todo === undefined || data.todo === false) {
|
||||
|
||||
@@ -84,7 +84,7 @@ const {
|
||||
sourceMaps,
|
||||
testNamePatterns,
|
||||
testSkipPatterns,
|
||||
testOnlyFlag,
|
||||
only: testOnlyFlag,
|
||||
updateSnapshots,
|
||||
} = parseCommandLine();
|
||||
let kResistStopPropagation;
|
||||
|
||||
@@ -197,19 +197,19 @@ function parseCommandLine() {
|
||||
const forceExit = getOptionValue('--test-force-exit');
|
||||
const sourceMaps = getOptionValue('--enable-source-maps');
|
||||
const updateSnapshots = getOptionValue('--test-update-snapshots');
|
||||
const watchMode = getOptionValue('--watch');
|
||||
const watch = getOptionValue('--watch');
|
||||
const isChildProcess = process.env.NODE_TEST_CONTEXT === 'child';
|
||||
const isChildProcessV8 = process.env.NODE_TEST_CONTEXT === 'child-v8';
|
||||
let concurrency;
|
||||
let coverageExcludeGlobs;
|
||||
let coverageIncludeGlobs;
|
||||
let destinations;
|
||||
let perFileTimeout;
|
||||
let only;
|
||||
let reporters;
|
||||
let runnerConcurrency;
|
||||
let shard;
|
||||
let testNamePatterns;
|
||||
let testSkipPatterns;
|
||||
let testOnlyFlag;
|
||||
let shard;
|
||||
let timeout;
|
||||
|
||||
if (isChildProcessV8) {
|
||||
kBuiltinReporters.set('v8-serializer', 'internal/test_runner/reporter/v8-serializer');
|
||||
@@ -239,9 +239,9 @@ function parseCommandLine() {
|
||||
}
|
||||
|
||||
if (isTestRunner) {
|
||||
perFileTimeout = getOptionValue('--test-timeout') || Infinity;
|
||||
runnerConcurrency = getOptionValue('--test-concurrency') || true;
|
||||
testOnlyFlag = false;
|
||||
timeout = getOptionValue('--test-timeout') || Infinity;
|
||||
concurrency = getOptionValue('--test-concurrency') || true;
|
||||
only = false;
|
||||
testNamePatterns = null;
|
||||
|
||||
const shardOption = getOptionValue('--test-shard');
|
||||
@@ -262,10 +262,10 @@ function parseCommandLine() {
|
||||
};
|
||||
}
|
||||
} else {
|
||||
perFileTimeout = Infinity;
|
||||
runnerConcurrency = 1;
|
||||
timeout = Infinity;
|
||||
concurrency = 1;
|
||||
const testNamePatternFlag = getOptionValue('--test-name-pattern');
|
||||
testOnlyFlag = getOptionValue('--test-only');
|
||||
only = getOptionValue('--test-only');
|
||||
testNamePatterns = testNamePatternFlag?.length > 0 ?
|
||||
ArrayPrototypeMap(
|
||||
testNamePatternFlag,
|
||||
@@ -284,21 +284,21 @@ function parseCommandLine() {
|
||||
globalTestOptions = {
|
||||
__proto__: null,
|
||||
isTestRunner,
|
||||
concurrency,
|
||||
coverage,
|
||||
coverageExcludeGlobs,
|
||||
coverageIncludeGlobs,
|
||||
destinations,
|
||||
forceExit,
|
||||
perFileTimeout,
|
||||
runnerConcurrency,
|
||||
only,
|
||||
reporters,
|
||||
shard,
|
||||
sourceMaps,
|
||||
testOnlyFlag,
|
||||
testNamePatterns,
|
||||
testSkipPatterns,
|
||||
timeout,
|
||||
updateSnapshots,
|
||||
reporters,
|
||||
destinations,
|
||||
watchMode,
|
||||
watch,
|
||||
};
|
||||
|
||||
return globalTestOptions;
|
||||
|
||||
Reference in new issue
Block a user