From 8df606c22e789f372de8d9d28db08c3357a6f5aa Mon Sep 17 00:00:00 2001 From: Saiteja Bandaru Date: Wed, 29 Jul 2026 15:35:39 +0200 Subject: [PATCH] test_runner: do not read from process.argv and process.cwd() in run() Currently the codebase for `runner.js` accesses some properties of `process`, capturing options there. However, since `run()` is exposed to end users, we should capture all this information in `lib/internal/main/test_runner.js` and pass it down to `run()` as options. This commit updates `run()` to default `cwd` to `.` instead of reading `process.cwd()`, and substitutes `process.execArgv` with the provided `execArgv` option when propagating V8 flags. It also updates `test_runner.js` to explicitly pass these options. --- lib/internal/main/test_runner.js | 2 ++ lib/internal/test_runner/runner.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/main/test_runner.js b/lib/internal/main/test_runner.js index fda47897da9f..49ea966a21ee 100644 --- a/lib/internal/main/test_runner.js +++ b/lib/internal/main/test_runner.js @@ -31,6 +31,8 @@ if (isUsingInspector() && options.isolation === 'process') { } options.globPatterns = ArrayPrototypeSlice(process.argv, 1); +options.cwd = process.cwd(); +options.execArgv = process.execArgv; debug('test runner configuration:', options); run(options).on('test:summary', (data) => { diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 3bfe719ce5be..ba883d263978 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -207,7 +207,7 @@ function getRunArgs(path, { forceExit, */ const nodeOptionsSet = new SafeSet(processNodeOptions); const unknownProcessExecArgv = ArrayPrototypeFilter( - process.execArgv, + execArgv, (arg, i, arr) => !nodeOptionsSet.has(arg) && filterExecArgv(arg, i, arr), ); ArrayPrototypePushApply(runArgs, unknownProcessExecArgv); @@ -730,7 +730,7 @@ function run(options = kEmptyObject) { randomSeed: suppliedRandomSeed, execArgv = [], argv = [], - cwd = process.cwd(), + cwd = '.', rerunFailuresFilePath, env, } = options;