mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: add already-aborted-controller test for spawn()
PR-URL: https://github.com/nodejs/node/pull/36644 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
This commit is contained in:
parent
36394b6782
commit
37acaf668d
@ -4,18 +4,38 @@ const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
|
||||
// Verify that passing an AbortSignal works
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
{
|
||||
// Verify that passing an AbortSignal works
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
|
||||
const echo = cp.spawn('echo', ['fun'], {
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
signal
|
||||
});
|
||||
const echo = cp.spawn('echo', ['fun'], {
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
signal
|
||||
});
|
||||
|
||||
echo.on('error', common.mustCall((e) => {
|
||||
assert.strictEqual(e.name, 'AbortError');
|
||||
}));
|
||||
echo.on('error', common.mustCall((e) => {
|
||||
assert.strictEqual(e.name, 'AbortError');
|
||||
}));
|
||||
|
||||
controller.abort();
|
||||
controller.abort();
|
||||
}
|
||||
|
||||
{
|
||||
// Verify that passing an already-aborted signal works.
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
|
||||
controller.abort();
|
||||
|
||||
const echo = cp.spawn('echo', ['fun'], {
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
signal
|
||||
});
|
||||
|
||||
echo.on('error', common.mustCall((e) => {
|
||||
assert.strictEqual(e.name, 'AbortError');
|
||||
}));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user