mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
test_runner: propagate V8 options to child process
PR-URL: https://github.com/nodejs/node/pull/60999 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
This commit is contained in:
parent
0624e7a180
commit
410174c3c4
@ -154,6 +154,22 @@ function getRunArgs(path, { forceExit,
|
||||
cwd }) {
|
||||
const processNodeOptions = getOptionsAsFlagsFromBinding();
|
||||
const runArgs = ArrayPrototypeFilter(processNodeOptions, filterExecArgv);
|
||||
|
||||
/**
|
||||
* Node supports V8 options passed via cli.
|
||||
* These options are being consumed by V8 and are not stored in nodeOptions.
|
||||
*
|
||||
* We need to propagate these options to the child processes manually.
|
||||
*
|
||||
* An example of such option are --allow-natives-syntax and --expose-gc
|
||||
*/
|
||||
const nodeOptionsSet = new SafeSet(processNodeOptions);
|
||||
const unknownProcessExecArgv = ArrayPrototypeFilter(
|
||||
process.execArgv,
|
||||
(arg) => !nodeOptionsSet.has(arg),
|
||||
);
|
||||
ArrayPrototypePushApply(runArgs, unknownProcessExecArgv);
|
||||
|
||||
if (forceExit === true) {
|
||||
ArrayPrototypePush(runArgs, '--test-force-exit');
|
||||
}
|
||||
|
||||
7
test/fixtures/test-runner/flag-propagation/issue-60986.mjs
vendored
Normal file
7
test/fixtures/test-runner/flag-propagation/issue-60986.mjs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
describe("test", () => {
|
||||
it("calls gc", () => {
|
||||
globalThis.gc();
|
||||
});
|
||||
});
|
||||
@ -125,4 +125,28 @@ describe('test runner flag propagation', () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('V8 specific flags', () => {
|
||||
const v8FlagTestFixture = path.join(fixtureDir, 'issue-60986.mjs');
|
||||
it('should propagate V8 only flags to child tests', () => {
|
||||
|
||||
const child = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--allow-natives-syntax',
|
||||
'--expose-gc',
|
||||
'--test',
|
||||
v8FlagTestFixture,
|
||||
],
|
||||
{
|
||||
cwd: fixtureDir,
|
||||
},
|
||||
);
|
||||
|
||||
assert.strictEqual(child.status, 0, `V8 flag propagation test failed.`);
|
||||
const stdout = child.stdout.toString();
|
||||
assert.match(stdout, /tests 1/, `Test should execute for V8 flag propagation`);
|
||||
assert.match(stdout, /pass 1/, `Test should pass for V8 flag propagation check`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user