test_runner: fix timeout not propagated to the child process in run

PR-URL: https://github.com/nodejs/node/pull/58831
Fixes: https://github.com/nodejs/node/issues/58802
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Adrian Estrada <edsadr@gmail.com>
This commit is contained in:
jakecastelli 2025-06-27 21:20:17 +09:30 committed by GitHub
parent 488febf856
commit 94f7568e5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -145,6 +145,7 @@ function getRunArgs(path, { forceExit,
only,
argv: suppliedArgs,
execArgv,
root: { timeout },
cwd }) {
const argv = ArrayPrototypeFilter(process.execArgv, filterExecArgv);
if (forceExit === true) {
@ -162,6 +163,9 @@ function getRunArgs(path, { forceExit,
if (only === true) {
ArrayPrototypePush(argv, '--test-only');
}
if (timeout != null) {
ArrayPrototypePush(argv, `--test-timeout=${timeout}`);
}
ArrayPrototypePushApply(argv, execArgv);

View File

@ -88,9 +88,11 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
it('should support timeout', async () => {
const stream = run({ timeout: 50, files: [
fixtures.path('test-runner', 'timeout-basic.mjs'),
fixtures.path('test-runner', 'plan', 'timeout-basic.mjs'),
] });
stream.on('test:fail', common.mustCall(1));
stream.on('test:fail', common.mustCall((data) => {
assert.strictEqual(data.details.error.failureType, 'testTimeoutFailure');
}, 2));
stream.on('test:pass', common.mustNotCall());
// eslint-disable-next-line no-unused-vars
for await (const _ of stream);