diff --git a/lib/internal/main/test_runner.js b/lib/internal/main/test_runner.js index fda47897da9f06..9d446925c00b88 100644 --- a/lib/internal/main/test_runner.js +++ b/lib/internal/main/test_runner.js @@ -31,6 +31,7 @@ if (isUsingInspector() && options.isolation === 'process') { } options.globPatterns = ArrayPrototypeSlice(process.argv, 1); +options.processExecArgv = 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 d150943783e975..d018e6100602ef 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -187,6 +187,8 @@ function getRunArgs(path, { forceExit, only, argv: suppliedArgs, execArgv, + processExecArgv, + globPatterns, rerunFailuresFilePath, randomize, randomSeed, @@ -205,7 +207,7 @@ function getRunArgs(path, { forceExit, */ const nodeOptionsSet = new SafeSet(processNodeOptions); const unknownProcessExecArgv = ArrayPrototypeFilter( - process.execArgv, + processExecArgv, (arg) => !nodeOptionsSet.has(arg), ); ArrayPrototypePushApply(runArgs, unknownProcessExecArgv); @@ -245,7 +247,7 @@ function getRunArgs(path, { forceExit, if (path === kIsolatedProcessName) { ArrayPrototypePush(runArgs, '--test'); - ArrayPrototypePushApply(runArgs, ArrayPrototypeSlice(process.argv, 1)); + ArrayPrototypePushApply(runArgs, globPatterns); } else { ArrayPrototypePush(runArgs, path); } @@ -723,6 +725,7 @@ function run(options = kEmptyObject) { randomSeed: suppliedRandomSeed, execArgv = [], argv = [], + processExecArgv = process.execArgv, cwd = process.cwd(), rerunFailuresFilePath, env, @@ -981,6 +984,7 @@ function run(options = kEmptyObject) { isolation, argv, execArgv, + processExecArgv, rerunFailuresFilePath, env, workerIdPool: isolation === 'process' ? workerIdPool : null, diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index b6eb6b6af51877..d15f5b82ac96e1 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -727,6 +727,28 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { })); }); + it('should accept processExecArgv option and default to process.execArgv', async () => { + const stream = run({ + files: [join(testFixtures, 'default-behavior/test/random.cjs')], + processExecArgv: process.execArgv, + }); + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall()); + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should accept empty processExecArgv', async () => { + const stream = run({ + files: [join(testFixtures, 'default-behavior/test/random.cjs')], + processExecArgv: [], + }); + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall()); + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + it('should pass instance of stream to setup', async () => { const stream = run({ files: [join(testFixtures, 'default-behavior/test/random.cjs')],