Skip to content

Commit d0faf72

Browse files
jakecastellitargos
authored andcommitted
test_runner: fix timeout not propagated to the child process in run
PR-URL: #58831 Fixes: #58802 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Adrian Estrada <[email protected]>
1 parent 6e6b373 commit d0faf72

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/internal/test_runner/runner.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function getRunArgs(path, { forceExit,
145145
only,
146146
argv: suppliedArgs,
147147
execArgv,
148+
root: { timeout },
148149
cwd }) {
149150
const argv = ArrayPrototypeFilter(process.execArgv, filterExecArgv);
150151
if (forceExit === true) {
@@ -162,6 +163,9 @@ function getRunArgs(path, { forceExit,
162163
if (only === true) {
163164
ArrayPrototypePush(argv, '--test-only');
164165
}
166+
if (timeout != null) {
167+
ArrayPrototypePush(argv, `--test-timeout=${timeout}`);
168+
}
165169

166170
ArrayPrototypePushApply(argv, execArgv);
167171

test/parallel/test-runner-run.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
8888

8989
it('should support timeout', async () => {
9090
const stream = run({ timeout: 50, files: [
91-
fixtures.path('test-runner', 'timeout-basic.mjs'),
91+
fixtures.path('test-runner', 'plan', 'timeout-basic.mjs'),
9292
] });
93-
stream.on('test:fail', common.mustCall(1));
93+
stream.on('test:fail', common.mustCall((data) => {
94+
assert.strictEqual(data.details.error.failureType, 'testTimeoutFailure');
95+
}, 2));
9496
stream.on('test:pass', common.mustNotCall());
9597
// eslint-disable-next-line no-unused-vars
9698
for await (const _ of stream);

0 commit comments

Comments
 (0)