Skip to content
Myr

kill.js

This file

Path

test/kill.js

345 lines · 13.1 KiB · JavaScript

Last changed by

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

History of this file

Take it

The walk stopped after 200 commits: lines older than 31ac967 point at it.

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 1why, one step back
1import process from 'node:process';

Improve process termination (#724)ehmickybefore adoption1c48d37

line 2why, one step back
2import {once} from 'node:events';

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

line 3why, one step back
3import {constants} from 'node:os';

Fix test about `SIGTERM` (#611)ehmickybefore adoption85a9821

line 4why, one step back
4import {setTimeout} from 'node:timers/promises';

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 5why, one step back
5import test from 'ava';

Minor tweaksSindre Sorhusbefore adoption244e87a

line 6why, one step back
6import {pEvent} from 'p-event';

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 7why, one step back
7import isRunning from 'is-running';

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 8why, one step back
8import {execa, execaSync} from '../index.js';

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 9why, one step back
9import {setFixtureDir} from './helpers/fixtures-dir.js';

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 10why, one step back
10

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 11why, one step back
11setFixtureDir();

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 12–14why, one step back
12
13const TIMEOUT_REGEXP = /timed out after/;14

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 15why, one step back
15const spawnNoKillable = async (forceKillAfterDelay, options) => {

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 16–17why, one step back
16 const subprocess = execa('no-killable.js', {
17 stdio: ['pipe', 'pipe', 'pipe', 'ipc'],

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 18why, one step back
18 forceKillAfterDelay,

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 19–20why, one step back
19 ...options,
20 });

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 21why, one step back
21 await pEvent(subprocess, 'message');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 22–23why, one step back
22 return {subprocess};
23};

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 24why, one step back
24

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 25–27why, one step back
25test('kill("SIGKILL") should terminate cleanly', async t => {
26 const {subprocess} = await spawnNoKillable();27

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 28–29why, one step back
28 subprocess.kill('SIGKILL');
29

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 30–31why, one step back
30 const {isTerminated, signal} = await t.throwsAsync(subprocess);
31 t.true(isTerminated);

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 32–37why, one step back
32 t.is(signal, 'SIGKILL');
33});3435// `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix).36// Therefore, this feature and those tests do not make sense on Windows.37if (process.platform !== 'win32') {

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 38–39why, one step back
38 const testNoForceKill = async (t, forceKillAfterDelay, killArgument, options) => {
39 const {subprocess} = await spawnNoKillable(forceKillAfterDelay, options);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 40why, one step back
40

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 41why, one step back
41 subprocess.kill(killArgument);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 42why, one step back
42

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 43why, one step back
43 await setTimeout(6e3);

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 44–46why, one step back
44 t.true(isRunning(subprocess.pid));
45 subprocess.kill('SIGKILL');46

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 47–48why, one step back
47 const {isTerminated, signal} = await t.throwsAsync(subprocess);
48 t.true(isTerminated);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 49why, one step back
49 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 50why, one step back
50 };

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 51why, one step back
51

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

lines 52–53why, one step back
52 test('`forceKillAfterDelay: false` should not kill after a timeout', testNoForceKill, false);
53 test('`forceKillAfterDelay` should not kill after a timeout with other signals', testNoForceKill, true, 'SIGINT');

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 54–55why, one step back
54 test('`forceKillAfterDelay` should not kill after a timeout with wrong killSignal string', testNoForceKill, true, 'SIGTERM', {killSignal: 'SIGINT'});
55 test('`forceKillAfterDelay` should not kill after a timeout with wrong killSignal number', testNoForceKill, true, constants.signals.SIGTERM, {killSignal: constants.signals.SIGINT});

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 56why, one step back
56

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 57–58why, one step back
57 const testForceKill = async (t, forceKillAfterDelay, killArgument, options) => {
58 const {subprocess} = await spawnNoKillable(forceKillAfterDelay, options);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 59why, one step back
59

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 60–63why, one step back
60 subprocess.kill(killArgument);
6162 const {isTerminated, signal} = await t.throwsAsync(subprocess);63 t.true(isTerminated);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 64why, one step back
64 t.is(signal, 'SIGKILL');

Improve some tests (#655)ehmickybefore adoption6cf1c5e

line 65why, one step back
65 };

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 66why, one step back
66

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

lines 67–69why, one step back
67 test('`forceKillAfterDelay: number` should kill after a timeout', testForceKill, 50);
68 test('`forceKillAfterDelay: true` should kill after a timeout', testForceKill, true);69 test('`forceKillAfterDelay: undefined` should kill after a timeout', testForceKill, undefined);

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 70–72why, one step back
70 test('`forceKillAfterDelay` should kill after a timeout with SIGTERM', testForceKill, 50, 'SIGTERM');
71 test('`forceKillAfterDelay` should kill after a timeout with the killSignal string', testForceKill, 50, 'SIGINT', {killSignal: 'SIGINT'});72 test('`forceKillAfterDelay` should kill after a timeout with the killSignal number', testForceKill, 50, constants.signals.SIGINT, {killSignal: constants.signals.SIGINT});

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 73why, one step back
73

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 74why, one step back
74 const testInvalidForceKill = async (t, forceKillAfterDelay) => {

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 75why, one step back
75 t.throws(() => {

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 76why, one step back
76 execa('empty.js', {forceKillAfterDelay});

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 77why, one step back
77 }, {instanceOf: TypeError, message: /non-negative integer/});

Improve some tests (#655)ehmickybefore adoption6cf1c5e

line 78why, one step back
78 };

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 79why, one step back
79

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

lines 80–81why, one step back
80 test('`forceKillAfterDelay` should not be NaN', testInvalidForceKill, Number.NaN);
81 test('`forceKillAfterDelay` should not be negative', testInvalidForceKill, -1);

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 82why, one step back
82

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 83why, one step back
83 test('`forceKillAfterDelay` works with the "signal" option', async t => {

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 84why, one step back
84 const abortController = new AbortController();

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 85–86why, one step back
85 const subprocess = execa('forever.js', {killSignal: 'SIGWINCH', forceKillAfterDelay: 1, signal: abortController.signal});
86 await once(subprocess, 'spawn');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 87–88why, one step back
87 abortController.abort();
88 const {isTerminated, signal, isCanceled} = await t.throwsAsync(subprocess);

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 89–90why, one step back
89 t.true(isTerminated);
90 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 91–93why, one step back
91 t.true(isCanceled);
92 });93

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 94–95why, one step back
94 test('`forceKillAfterDelay` works with the "timeout" option', async t => {
95 const subprocess = execa('forever.js', {killSignal: 'SIGWINCH', forceKillAfterDelay: 1, timeout: 1});

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 96–97why, one step back
96 const {isTerminated, signal, timedOut} = await t.throwsAsync(subprocess);
97 t.true(isTerminated);

Improve process termination (#724)ehmickybefore adoption1c48d37

line 98why, one step back
98 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 99–101why, one step back
99 t.true(timedOut);
100 });101

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 102why, one step back
102 test('`forceKillAfterDelay` works with the "maxBuffer" option', async t => {

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

line 103why, one step back
103 const subprocess = execa('noop-forever.js', ['.'], {killSignal: 'SIGWINCH', forceKillAfterDelay: 1, maxBuffer: 1});

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 104why, one step back
104 const {isTerminated, signal} = await t.throwsAsync(subprocess);

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 105–106why, one step back
105 t.true(isTerminated);
106 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 107–108why, one step back
107 });
108

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 109why, one step back
109 test('`forceKillAfterDelay` works with "error" events on childProcess', async t => {

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 110–111why, one step back
110 const subprocess = execa('forever.js', {killSignal: 'SIGWINCH', forceKillAfterDelay: 1});
111 await once(subprocess, 'spawn');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 112–113why, one step back
112 subprocess.emit('error', new Error('test'));
113 const {isTerminated, signal} = await t.throwsAsync(subprocess);

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 114–115why, one step back
114 t.true(isTerminated);
115 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 116–117why, one step back
116 });
117

Rename `forceKillAfterTimeout` to `forceKillAfterDelay` (#723)ehmickybefore adoption0ff8b34

line 118why, one step back
118 test('`forceKillAfterDelay` works with "error" events on childProcess.stdout', async t => {

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 119–120why, one step back
119 const subprocess = execa('forever.js', {killSignal: 'SIGWINCH', forceKillAfterDelay: 1});
120 await once(subprocess, 'spawn');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

lines 121–122why, one step back
121 subprocess.stdout.destroy(new Error('test'));
122 const {isTerminated, signal} = await t.throwsAsync(subprocess);

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 123–124why, one step back
123 t.true(isTerminated);
124 t.is(signal, 'SIGKILL');

Improve graceful exit (#714)ehmickybefore adoption5eeaab5

line 125why, one step back
125 });

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 126–127why, one step back
126}
127

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 128–131why, one step back
128test('execa() returns a promise with kill()', async t => {
129 const subprocess = execa('noop.js', ['foo']);130 t.is(typeof subprocess.kill, 'function');131 await subprocess;

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 132–134why, one step back
132});
133134test('timeout kills the process if it times out', async t => {

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

line 135why, one step back
135 const {isTerminated, signal, timedOut} = await t.throwsAsync(execa('forever.js', {timeout: 1}), {message: TIMEOUT_REGEXP});

Fix `error.killed` and rename to `error.isTerminated` (#625)ehmickybefore adoption248349c

line 136why, one step back
136 t.true(isTerminated);

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

line 137why, one step back
137 t.is(signal, 'SIGTERM');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 138–141why, one step back
138 t.true(timedOut);
139});140141test('timeout kills the process if it times out, in sync mode', async t => {

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

lines 142–143why, one step back
142 const {isTerminated, signal, timedOut} = await t.throws(() => {
143 execaSync('forever.js', {timeout: 1, message: TIMEOUT_REGEXP});

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 144why, one step back
144 });

Fix `error.killed` and rename to `error.isTerminated` (#625)ehmickybefore adoption248349c

line 145why, one step back
145 t.true(isTerminated);

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

line 146why, one step back
146 t.is(signal, 'SIGTERM');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 147–150why, one step back
147 t.true(timedOut);
148});149150test('timeout does not kill the process if it does not time out', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 151why, one step back
151 const {timedOut} = await execa('delay.js', ['500'], {timeout: 1e8});

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 152–154why, one step back
152 t.false(timedOut);
153});154

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 155–161why, one step back
155test('timeout uses killSignal', async t => {
156 const {isTerminated, signal, timedOut} = await t.throwsAsync(execa('forever.js', {timeout: 1, killSignal: 'SIGINT'}));157 t.true(isTerminated);158 t.is(signal, 'SIGINT');159 t.true(timedOut);160});161

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 162–163why, one step back
162const INVALID_TIMEOUT_REGEXP = /`timeout` option to be a non-negative integer/;
163

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

lines 164–166why, one step back
164const testTimeoutValidation = (t, timeout, execaMethod) => {
165 t.throws(() => {166 execaMethod('empty.js', {timeout});

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 167why, one step back
167 }, {message: INVALID_TIMEOUT_REGEXP});

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

line 168why, one step back
168};

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 169why, one step back
169

Improve `timeout` option validation (#715)ehmickybefore adoption0fbd3a2

lines 170–173why, one step back
170test('timeout must not be negative', testTimeoutValidation, -1, execa);
171test('timeout must be an integer', testTimeoutValidation, false, execa);172test('timeout must not be negative - sync', testTimeoutValidation, -1, execaSync);173test('timeout must be an integer - sync', testTimeoutValidation, false, execaSync);

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 174–175why, one step back
174
175test('timedOut is false if timeout is undefined', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 176why, one step back
176 const {timedOut} = await execa('noop.js');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 177–180why, one step back
177 t.false(timedOut);
178});179180test('timedOut is false if timeout is 0', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 181why, one step back
181 const {timedOut} = await execa('noop.js', {timeout: 0});

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 182–185why, one step back
182 t.false(timedOut);
183});184185test('timedOut is false if timeout is undefined and exit code is 0 in sync mode', t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 186why, one step back
186 const {timedOut} = execaSync('noop.js');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 187–191why, one step back
187 t.false(timedOut);
188});189190// When child process exits before parent process191const spawnAndExit = async (t, cleanup, detached) => {

Fix randomly failing test (#725)ehmickybefore adoption1fbf484

line 192why, one step back
192 await t.notThrowsAsync(execa('nested.js', [JSON.stringify({cleanup, detached}), 'noop.js']));

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 193–200why, one step back
193};
194195test('spawnAndExit', spawnAndExit, false, false);196test('spawnAndExit cleanup', spawnAndExit, true, false);197test('spawnAndExit detached', spawnAndExit, false, true);198test('spawnAndExit cleanup detached', spawnAndExit, true, true);199200// When parent process exits before child process

Fix linting errors (#462)ehmickybefore adoption8e4f901

line 201why, one step back
201const spawnAndKill = async (t, [signal, cleanup, detached, isKilled]) => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 202why, one step back
202 const subprocess = execa('sub-process.js', [cleanup, detached], {stdio: ['ignore', 'ignore', 'ignore', 'ipc']});

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 203–212why, one step back
203
204 const pid = await pEvent(subprocess, 'message');205 t.true(Number.isInteger(pid));206 t.true(isRunning(pid));207208 process.kill(subprocess.pid, signal);209210 await t.throwsAsync(subprocess);211 t.false(isRunning(subprocess.pid));212

Fix randomly failing test (#725)ehmickybefore adoption1fbf484

lines 213–220why, one step back
213 if (isKilled) {
214 await Promise.race([215 setTimeout(1e4, undefined, {ref: false}),216 pollForProcessExit(pid),217 ]);218 t.is(isRunning(pid), false);219 } else {220 t.is(isRunning(pid), true);

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 221–224why, one step back
221 process.kill(pid, 'SIGKILL');
222 }223};224

Fix randomly failing test (#725)ehmickybefore adoption1fbf484

lines 225–231why, one step back
225const pollForProcessExit = async pid => {
226 while (isRunning(pid)) {227 // eslint-disable-next-line no-await-in-loop228 await setTimeout(100);229 }230};231

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 232–238why, one step back
232// Without `options.cleanup`:
233// - on Windows subprocesses are killed if `options.detached: false`, but not234// if `options.detached: true`235// - on Linux subprocesses are never killed regardless of `options.detached`236// With `options.cleanup`, subprocesses are always killed237// - `options.cleanup` with SIGKILL is a noop, since it cannot be handled238const exitIfWindows = process.platform === 'win32';

Fix linting errors (#462)ehmickybefore adoption8e4f901

lines 239–240why, one step back
239test('spawnAndKill SIGTERM', spawnAndKill, ['SIGTERM', false, false, exitIfWindows]);
240test('spawnAndKill SIGKILL', spawnAndKill, ['SIGKILL', false, false, exitIfWindows]);

Fix randomly failing test (#725)ehmickybefore adoption1fbf484

line 241why, one step back
241test('spawnAndKill cleanup SIGTERM', spawnAndKill, ['SIGTERM', true, false, true]);

Fix linting errors (#462)ehmickybefore adoption8e4f901

lines 242–246why, one step back
242test('spawnAndKill cleanup SIGKILL', spawnAndKill, ['SIGKILL', true, false, exitIfWindows]);
243test('spawnAndKill detached SIGTERM', spawnAndKill, ['SIGTERM', false, true, false]);244test('spawnAndKill detached SIGKILL', spawnAndKill, ['SIGKILL', false, true, false]);245test('spawnAndKill cleanup detached SIGTERM', spawnAndKill, ['SIGTERM', true, true, false]);246test('spawnAndKill cleanup detached SIGKILL', spawnAndKill, ['SIGKILL', true, true, false]);

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 247–249why, one step back
247
248// See #128249test('removes exit handler on exit', async t => {

Fix linting errors (#462)ehmickybefore adoption8e4f901

line 250why, one step back
250 // @todo this relies on `signal-exit` internals

Refactor `timeout` option to use `async/await` (#650)ehmickybefore adoption76ff50b

line 251why, one step back
251 const exitListeners = globalThis[Symbol.for('signal-exit emitter')].listeners.exit;

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 252why, one step back
252

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 253why, one step back
253 const subprocess = execa('noop.js');

Refactor `timeout` option to use `async/await` (#650)ehmickybefore adoption76ff50b

line 254why, one step back
254 const listener = exitListeners.at(-1);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 255why, one step back
255

Refactor `timeout` option to use `async/await` (#650)ehmickybefore adoption76ff50b

lines 256–257why, one step back
256 await subprocess;
257 t.false(exitListeners.includes(listener));

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 258–259why, one step back
258});
259

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 260why, one step back
260test('result.isCanceled is false when abort isn\'t called (success)', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 261why, one step back
261 const {isCanceled} = await execa('noop.js');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 262–264why, one step back
262 t.false(isCanceled);
263});264

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 265why, one step back
265test('result.isCanceled is false when abort isn\'t called (failure)', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 266why, one step back
266 const {isCanceled} = await t.throwsAsync(execa('fail.js'));

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 267–269why, one step back
267 t.false(isCanceled);
268});269

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 270why, one step back
270test('result.isCanceled is false when abort isn\'t called in sync mode (success)', t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 271why, one step back
271 const {isCanceled} = execaSync('noop.js');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 272–274why, one step back
272 t.false(isCanceled);
273});274

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 275why, one step back
275test('result.isCanceled is false when abort isn\'t called in sync mode (failure)', t => {

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 276why, one step back
276 const {isCanceled} = t.throws(() => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 277why, one step back
277 execaSync('fail.js');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 278–281why, one step back
278 });
279 t.false(isCanceled);280});281

Improve process termination (#724)ehmickybefore adoption1c48d37

line 282why, one step back
282test('calling abort is considered a signal termination', async t => {

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 283why, one step back
283 const abortController = new AbortController();

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 284–285why, one step back
284 const subprocess = execa('forever.js', {signal: abortController.signal});
285 await once(subprocess, 'spawn');

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 286–287why, one step back
286 abortController.abort();
287 const {isTerminated, signal} = await t.throwsAsync(subprocess);

Improve process termination (#724)ehmickybefore adoption1c48d37

lines 288–289why, one step back
288 t.true(isTerminated);
289 t.is(signal, 'SIGTERM');

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 290–291why, one step back
290});
291

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 292–295why, one step back
292test('error.isCanceled is true when abort is used', async t => {
293 const abortController = new AbortController();294 const subprocess = execa('noop.js', {signal: abortController.signal});295 abortController.abort();

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 296–300why, one step back
296 const {isCanceled} = await t.throwsAsync(subprocess);
297 t.true(isCanceled);298});299300test('error.isCanceled is false when kill method is used', async t => {

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 301–302why, one step back
301 const abortController = new AbortController();
302 const subprocess = execa('noop.js', {signal: abortController.signal});

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 303–307why, one step back
303 subprocess.kill();
304 const {isCanceled} = await t.throwsAsync(subprocess);305 t.false(isCanceled);306});307

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 308–312why, one step back
308test('calling abort throws an error with message "Command was canceled"', async t => {
309 const abortController = new AbortController();310 const subprocess = execa('noop.js', {signal: abortController.signal});311 abortController.abort();312 await t.throwsAsync(subprocess, {message: /Command was canceled/});

Add `serialization` option (#392)ehmickybefore adoption31ac967

lines 313–314why, one step back
313});
314

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 315–319why, one step back
315test('calling abort twice should show the same behaviour as calling it once', async t => {
316 const abortController = new AbortController();317 const subprocess = execa('noop.js', {signal: abortController.signal});318 abortController.abort();319 abortController.abort();

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 320why, one step back
320 const {isCanceled} = await t.throwsAsync(subprocess);

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 321why, one step back
321 t.true(isCanceled);

Add `serialization` option (#392)ehmickybefore adoption31ac967

line 322why, one step back
322});

Support `AbortController` (#490)Gyubongbefore adoptionc6e791a

line 323why, one step back
323

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

lines 324–329why, one step back
324test('calling abort on a successfully completed process does not make result.isCanceled true', async t => {
325 const abortController = new AbortController();326 const subprocess = execa('noop.js', {signal: abortController.signal});327 const result = await subprocess;328 abortController.abort();329 t.false(result.isCanceled);

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 330–344why, one step back
330});
331332test('child process errors are handled', async t => {333 const subprocess = execa('forever.js');334 subprocess.emit('error', new Error('test'));335 await t.throwsAsync(subprocess, {message: 'Command failed: forever.js\ntest'});336});337338test('child process errors use killSignal', async t => {339 const subprocess = execa('forever.js', {killSignal: 'SIGINT'});340 await once(subprocess, 'spawn');341 subprocess.emit('error', new Error('test'));342 const {isTerminated, signal} = await t.throwsAsync(subprocess, {message: /test/});343 t.true(isTerminated);344 t.is(signal, 'SIGINT');

Remove `.cancel()` method (#711)ehmickybefore adoption16e5fd6

line 345why, one step back
345});