exit.js
This file
Path
test/resolve/exit.js
85 lines · 2.8 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 2why, one step back2import process from 'node:process';TweaksSindre Sorhusbefore adoption698a1b8
lines 3–4why, one step back3import test from 'node:test';4import {assertRejects} from '../helpers/assert.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 5–11why, one step back5import {execa} from '../../index.js';6import {setFixtureDirectory} from '../helpers/fixtures-directory.js';78const isWindows = process.platform === 'win32';910setFixtureDirectory();11TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12test('exitCode is 0 on success', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 13why, one step back13 const {exitCode} = await execa('noop.js', ['foo']);TweaksSindre Sorhusbefore adoption698a1b8
line 14why, one step back14 assert.equal(exitCode, 0);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 15–16why, one step back15});16TweaksSindre Sorhusbefore adoption698a1b8
lines 17–22why, one step back17const testExitCode = async expectedExitCode => {18 const {exitCode, originalMessage, shortMessage, message} = await assertRejects(execa('exit.js', [`${expectedExitCode}`]));19 assert.equal(exitCode, expectedExitCode);20 assert.equal(originalMessage, undefined);21 assert.equal(shortMessage, `Command failed with exit code ${expectedExitCode}: exit.js ${expectedExitCode}`);22 assert.equal(message, shortMessage);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 23–24why, one step back23};24TweaksSindre Sorhusbefore adoption698a1b8
lines 25–27why, one step back25test('exitCode is 2', () => testExitCode(2));26test('exitCode is 3', () => testExitCode(3));27test('exitCode is 4', () => testExitCode(4));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 28–29why, one step back2829if (!isWindows) {TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30 test('error.signal is SIGINT', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 31–34why, one step back31 const subprocess = execa('forever.js');3233 process.kill(subprocess.pid, 'SIGINT');34TweaksSindre Sorhusbefore adoption698a1b8
lines 35–36why, one step back35 const {signal} = await assertRejects(subprocess, {message: /was killed with SIGINT/});36 assert.equal(signal, 'SIGINT');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 37–38why, one step back37 });38TweaksSindre Sorhusbefore adoption698a1b8
line 39why, one step back39 test('error.signalDescription is defined', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 40–43why, one step back40 const subprocess = execa('forever.js');4142 process.kill(subprocess.pid, 'SIGINT');43TweaksSindre Sorhusbefore adoption698a1b8
lines 44–45why, one step back44 const {signalDescription} = await assertRejects(subprocess, {message: /User interruption with CTRL-C/});45 assert.equal(signalDescription, 'User interruption with CTRL-C');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 46–47why, one step back46 });47TweaksSindre Sorhusbefore adoption698a1b8
line 48why, one step back48 test('error.signal is SIGTERM', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 49–52why, one step back49 const subprocess = execa('forever.js');5051 process.kill(subprocess.pid, 'SIGTERM');52TweaksSindre Sorhusbefore adoption698a1b8
lines 53–54why, one step back53 const {signal} = await assertRejects(subprocess, {message: /was killed with SIGTERM/});54 assert.equal(signal, 'SIGTERM');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 55–56why, one step back55 });56TweaksSindre Sorhusbefore adoption698a1b8
lines 57–59why, one step back57 test('error.signal uses killSignal', async () => {58 const {signal} = await assertRejects(execa('forever.js', {killSignal: 'SIGINT', timeout: 1, message: /timed out after/}));59 assert.equal(signal, 'SIGINT');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 60–61why, one step back60 });61TweaksSindre Sorhusbefore adoption698a1b8
line 62why, one step back62 test('exitCode is undefined on signal termination', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 63–66why, one step back63 const subprocess = execa('forever.js');6465 process.kill(subprocess.pid);66TweaksSindre Sorhusbefore adoption698a1b8
lines 67–68why, one step back67 const {exitCode} = await assertRejects(subprocess);68 assert.equal(exitCode, undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 69–71why, one step back69 });70}71TweaksSindre Sorhusbefore adoption698a1b8
line 72why, one step back72test('result.signal is undefined for successful execution', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 73why, one step back73 const {signal} = await execa('noop.js');TweaksSindre Sorhusbefore adoption698a1b8
line 74why, one step back74 assert.equal(signal, undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 75–76why, one step back75});76TweaksSindre Sorhusbefore adoption698a1b8
lines 77–79why, one step back77test('result.signal is undefined if subprocess failed, but was not killed', async () => {78 const {signal} = await assertRejects(execa('fail.js'));79 assert.equal(signal, undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 80–81why, one step back80});81TweaksSindre Sorhusbefore adoption698a1b8
line 82why, one step back82test('result.signalDescription is undefined for successful execution', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 83why, one step back83 const {signalDescription} = await execa('noop.js');TweaksSindre Sorhusbefore adoption698a1b8
line 84why, one step back84 assert.equal(signalDescription, undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 85why, one step back85});