Skip to content

Commit 8df606c

Browse files
author
Saiteja Bandaru
committed
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.
1 parent 41525ab commit 8df606c

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/internal/main/test_runner.js

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

3333
options.globPatterns = ArrayPrototypeSlice(process.argv, 1);
34+
options.cwd = process.cwd();
35+
options.execArgv = process.execArgv;
3436

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

lib/internal/test_runner/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function getRunArgs(path, { forceExit,
207207
*/
208208
const nodeOptionsSet = new SafeSet(processNodeOptions);
209209
const unknownProcessExecArgv = ArrayPrototypeFilter(
210-
process.execArgv,
210+
execArgv,
211211
(arg, i, arr) => !nodeOptionsSet.has(arg) && filterExecArgv(arg, i, arr),
212212
);
213213
ArrayPrototypePushApply(runArgs, unknownProcessExecArgv);
@@ -730,7 +730,7 @@ function run(options = kEmptyObject) {
730730
randomSeed: suppliedRandomSeed,
731731
execArgv = [],
732732
argv = [],
733-
cwd = process.cwd(),
733+
cwd = '.',
734734
rerunFailuresFilePath,
735735
env,
736736
} = options;

0 commit comments

Comments
 (0)