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 f0dfe57

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
test: add already-aborted-controller test for spawn()
PR-URL: #36644 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent b98cc51 commit f0dfe57
Copy full SHA for f0dfe57

File tree

Expand file treeCollapse file tree

1 file changed

+32
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-child-process-spawn-controller.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-spawn-controller.js
+32-12Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,38 @@ const common = require('../common');
44
const assert = require('assert');
55
const cp = require('child_process');
66

7-
// Verify that passing an AbortSignal works
8-
const controller = new AbortController();
9-
const { signal } = controller;
7+
{
8+
// Verify that passing an AbortSignal works
9+
const controller = new AbortController();
10+
const { signal } = controller;
1011

11-
const echo = cp.spawn('echo', ['fun'], {
12-
encoding: 'utf8',
13-
shell: true,
14-
signal
15-
});
12+
const echo = cp.spawn('echo', ['fun'], {
13+
encoding: 'utf8',
14+
shell: true,
15+
signal
16+
});
1617

17-
echo.on('error', common.mustCall((e) => {
18-
assert.strictEqual(e.name, 'AbortError');
19-
}));
18+
echo.on('error', common.mustCall((e) => {
19+
assert.strictEqual(e.name, 'AbortError');
20+
}));
2021

21-
controller.abort();
22+
controller.abort();
23+
}
24+
25+
{
26+
// Verify that passing an already-aborted signal works.
27+
const controller = new AbortController();
28+
const { signal } = controller;
29+
30+
controller.abort();
31+
32+
const echo = cp.spawn('echo', ['fun'], {
33+
encoding: 'utf8',
34+
shell: true,
35+
signal
36+
});
37+
38+
echo.on('error', common.mustCall((e) => {
39+
assert.strictEqual(e.name, 'AbortError');
40+
}));
41+
}

0 commit comments

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