wait-subprocess.js
This file
Path
test/resolve/wait-subprocess.js
50 lines · 2.1 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
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–8why, one step back3import {execa, execaSync} from '../../index.js';4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {getStdio} from '../helpers/stdio.js';67setFixtureDirectory();8TweaksSindre Sorhusbefore adoption698a1b8
line 9why, one step back9const testIgnore = async (fdNumber, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 10why, one step back10 const result = await execaMethod('noop.js', getStdio(fdNumber, 'ignore'));TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11 assert.equal(result.stdio[fdNumber], undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 12–13why, one step back12};13TweaksSindre Sorhusbefore adoption698a1b8
lines 14–19why, one step back14test('stdout is undefined if ignored', () => testIgnore(1, execa));15test('stderr is undefined if ignored', () => testIgnore(2, execa));16test('stdio[*] is undefined if ignored', () => testIgnore(3, execa));17test('stdout is undefined if ignored - sync', () => testIgnore(1, execaSync));18test('stderr is undefined if ignored - sync', () => testIgnore(2, execaSync));19test('stdio[*] is undefined if ignored - sync', () => testIgnore(3, execaSync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 20why, one step back20TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21const testSubprocessEventsCleanup = async fixtureName => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 22why, one step back22 const subprocess = execa(fixtureName, {reject: false});TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23 assert.deepEqual(subprocess.nodeChildProcess.eventNames().map(String).sort(), ['error', 'exit', 'spawn']);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 24why, one step back24 await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 25why, one step back25 assert.deepEqual(subprocess.nodeChildProcess.eventNames(), []);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 26–27why, one step back26};27TweaksSindre Sorhusbefore adoption698a1b8
lines 28–29why, one step back28test('subprocess listeners are cleaned up on success', () => testSubprocessEventsCleanup('empty.js'));29test('subprocess listeners are cleaned up on failure', () => testSubprocessEventsCleanup('fail.js'));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 30why, one step back30TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31test('Aborting stdout should not abort stderr nor all', async () => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 32–34why, one step back32 const subprocess = execa('empty.js', {all: true});3334 subprocess.stdout.destroy();TweaksSindre Sorhusbefore adoption698a1b8
lines 35–37why, one step back35 assert.equal(subprocess.stdout.readable, false);36 assert.equal(subprocess.stderr.readable, true);37 assert.equal(subprocess.all.readable, true);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 38–40why, one step back3839 await subprocess;40TweaksSindre Sorhusbefore adoption698a1b8
lines 41–49why, one step back41 assert.equal(subprocess.stdout.readableEnded, false);42 assert.equal(subprocess.stdout.errored, null);43 assert.equal(subprocess.stdout.destroyed, true);44 assert.equal(subprocess.stderr.readableEnded, true);45 assert.equal(subprocess.stderr.errored, null);46 assert.equal(subprocess.stderr.destroyed, true);47 assert.equal(subprocess.all.readableEnded, true);48 assert.equal(subprocess.all.errored, null);49 assert.equal(subprocess.all.destroyed, true);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 50why, one step back50});