Skip to content

Commit 2717a31

Browse files
committed
test: pass processExecArgv to run() instead of reading process.execArgv directly
Captures process.execArgv at the CLI entry point (main/test_runner.js) and passes it through as an explicit option to run(). This removes direct reads of process.execArgv and process.argv inside getRunArgs() in the test runner. Changes: - Add processExecArgv option to run() (defaults to process.execArgv for backward compatibility) - Pass processExecArgv from main/test_runner.js to run() - Replace process.execArgv read in getRunArgs() with the passed option - Replace process.argv read in getRunArgs() with globPatterns Refs: #53867 Signed-off-by: AliMahmoudDev <123aliactionx5@gmail.com>
1 parent 73c592b commit 2717a31

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/internal/main/test_runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if (isUsingInspector() && options.isolation === 'process') {
3131
}
3232

3333
options.globPatterns = ArrayPrototypeSlice(process.argv, 1);
34+
options.processExecArgv = process.execArgv;
3435

3536
debug('test runner configuration:', options);
3637
run(options).on('test:summary', (data) => {

lib/internal/test_runner/runner.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ function getRunArgs(path, { forceExit,
187187
only,
188188
argv: suppliedArgs,
189189
execArgv,
190+
processExecArgv,
191+
globPatterns,
190192
rerunFailuresFilePath,
191193
randomize,
192194
randomSeed,
@@ -205,7 +207,7 @@ function getRunArgs(path, { forceExit,
205207
*/
206208
const nodeOptionsSet = new SafeSet(processNodeOptions);
207209
const unknownProcessExecArgv = ArrayPrototypeFilter(
208-
process.execArgv,
210+
processExecArgv,
209211
(arg) => !nodeOptionsSet.has(arg),
210212
);
211213
ArrayPrototypePushApply(runArgs, unknownProcessExecArgv);
@@ -245,7 +247,7 @@ function getRunArgs(path, { forceExit,
245247

246248
if (path === kIsolatedProcessName) {
247249
ArrayPrototypePush(runArgs, '--test');
248-
ArrayPrototypePushApply(runArgs, ArrayPrototypeSlice(process.argv, 1));
250+
ArrayPrototypePushApply(runArgs, globPatterns);
249251
} else {
250252
ArrayPrototypePush(runArgs, path);
251253
}
@@ -723,6 +725,7 @@ function run(options = kEmptyObject) {
723725
randomSeed: suppliedRandomSeed,
724726
execArgv = [],
725727
argv = [],
728+
processExecArgv = process.execArgv,
726729
cwd = process.cwd(),
727730
rerunFailuresFilePath,
728731
env,
@@ -981,6 +984,7 @@ function run(options = kEmptyObject) {
981984
isolation,
982985
argv,
983986
execArgv,
987+
processExecArgv,
984988
rerunFailuresFilePath,
985989
env,
986990
workerIdPool: isolation === 'process' ? workerIdPool : null,

0 commit comments

Comments
 (0)