Skip to content
Myr

Fix test about `SIGTERM` (#611)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 8638ce7 · Browse files · 1 file+9 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−4 removed

  • tests:+9 added−4 removed

1 file+9 added−4 removed

modified:test/kill.js+9 added-4 removed
1import process from 'node:process';2import {setTimeout} from 'node:timers/promises';3import test from 'ava';4import {pEvent} from 'p-event';5import isRunning from 'is-running';6import {execa, execaSync} from '../index.js';
143 unmodified lines
150 process.kill(subprocess.pid, signal);151152 await t.throwsAsync(subprocess);153154 // The `cleanup` option can introduce a race condition in this test.155 // This is especially true when run concurrently, so we use `test.serial()` and a manual timeout.156 if (signal === 'SIGTERM' && cleanup && !detached) {157 await setTimeout(1e3);158 }159160 t.false(isRunning(subprocess.pid));154 t.is(isRunning(pid), !isKilled);161 t.not(isRunning(pid), isKilled);162156 if (isRunning(pid)) {163 if (!isKilled) {164 process.kill(pid, 'SIGKILL');165 }166};167
5 unmodified lines
173// - `options.cleanup` with SIGKILL is a noop, since it cannot be handled174const exitIfWindows = process.platform === 'win32';175test('spawnAndKill SIGTERM', spawnAndKill, ['SIGTERM', false, false, exitIfWindows]);176test('spawnAndKill SIGKILL', spawnAndKill, ['SIGKILL', false, false, exitIfWindows]);170// The `cleanup` option can introduce a race condition in this test171// This is especially true when run concurrently, so we use `test.serial()`177test.serial('spawnAndKill cleanup SIGTERM', spawnAndKill, ['SIGTERM', true, false, true]);178test('spawnAndKill cleanup SIGKILL', spawnAndKill, ['SIGKILL', true, false, exitIfWindows]);179test('spawnAndKill detached SIGTERM', spawnAndKill, ['SIGTERM', false, true, false]);180test('spawnAndKill detached SIGKILL', spawnAndKill, ['SIGKILL', false, true, false]);
137 unmodified lines