Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 58d15b3

Browse filesBrowse files
MoLowdanielleadams
authored andcommitted
test_runner: pass signal on timeout
PR-URL: #43911 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 25ec71d commit 58d15b3
Copy full SHA for 58d15b3

File tree

Expand file treeCollapse file tree

3 files changed

+42
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+42
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/test.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ class Test extends AsyncResource {
414414
this.pass();
415415
} catch (err) {
416416
if (err?.code === 'ERR_TEST_FAILURE' && kIsNodeError in err) {
417-
this.fail(err);
417+
if (err.failureType === kTestTimeoutFailure) {
418+
this.cancel(err);
419+
} else {
420+
this.fail(err);
421+
}
418422
} else {
419423
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
420424
}
Collapse file

‎test/message/test_runner_output.out‎

Copy file name to clipboardExpand all lines: test/message/test_runner_output.out
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ not ok 13 - async assertion fail
129129
failureType: 'testCodeFailure'
130130
error: |-
131131
Expected values to be strictly equal:
132-
132+
133133
true !== false
134-
134+
135135
code: 'ERR_ASSERTION'
136136
stack: |-
137137
*
@@ -607,8 +607,8 @@ not ok 61 - invalid subtest fail
607607
# Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
608608
# tests 61
609609
# pass 26
610-
# fail 20
611-
# cancelled 0
610+
# fail 18
611+
# cancelled 2
612612
# skipped 10
613613
# todo 5
614614
# duration_ms *
Collapse file

‎test/parallel/test-runner-misc.js‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const { spawnSync } = require('child_process');
5+
const { setTimeout } = require('timers/promises');
6+
7+
if (process.argv[2] === 'child') {
8+
const test = require('node:test');
9+
10+
if (process.argv[3] === 'abortSignal') {
11+
assert.throws(() => test({ signal: {} }), {
12+
code: 'ERR_INVALID_ARG_TYPE',
13+
name: 'TypeError'
14+
});
15+
16+
let testSignal;
17+
test({ timeout: 10 }, common.mustCall(async ({ signal }) => {
18+
assert.strictEqual(signal.aborted, false);
19+
testSignal = signal;
20+
await setTimeout(50);
21+
})).finally(common.mustCall(() => {
22+
test(() => assert.strictEqual(testSignal.aborted, true));
23+
}));
24+
} else assert.fail('unreachable');
25+
} else {
26+
const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']);
27+
const stdout = child.stdout.toString();
28+
assert.match(stdout, /^# pass 1$/m);
29+
assert.match(stdout, /^# fail 0$/m);
30+
assert.match(stdout, /^# cancelled 1$/m);
31+
assert.strictEqual(child.status, 1);
32+
assert.strictEqual(child.signal, null);
33+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.