Skip to content

Commit 3215a58

Browse files
Trotttargos
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 e5fae63 commit 3215a58

1 file changed

Lines changed: 32 additions & 12 deletions

File tree

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

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,38 @@ const common = require('../common');
55
constassert=require('assert');
66
constcp=require('child_process');
77

8-
// Verify that passing an AbortSignal works
9-
constcontroller=newAbortController();
10-
const{ signal }=controller;
8+
{
9+
// Verify that passing an AbortSignal works
10+
constcontroller=newAbortController();
11+
const{ signal }=controller;
1112

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

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

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

0 commit comments

Comments
 (0)