exit.js
This file
Path
test/stream/exit.js
78 lines · 4.3 KiB · JavaScript
Last changed by
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–9why, one step back1import {once} from 'node:events';2import {setTimeout} from 'node:timers/promises';3import test from 'ava';4import {execa} from '../../index.js';5import {setFixtureDir} from '../helpers/fixtures-dir.js';6import {fullStdio, getStdio} from '../helpers/stdio.js';78setFixtureDir();9Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 10–11why, one step back10const testBufferIgnore = async (t, fdNumber, all) => {11 await t.notThrowsAsync(execa('max-buffer.js', [`${fdNumber}`], {...getStdio(fdNumber, 'ignore'), buffer: false, all}));Split files (#837)ehmickybefore adoption672c2d7
lines 12–13why, one step back12};13Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 14–16why, one step back14test('Subprocess buffers stdout, which does not prevent exit if ignored', testBufferIgnore, 1, false);15test('Subprocess buffers stderr, which does not prevent exit if ignored', testBufferIgnore, 2, false);16test('Subprocess buffers all, which does not prevent exit if ignored', testBufferIgnore, 1, true);Split files (#837)ehmickybefore adoption672c2d7
line 17why, one step back17Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 18–19why, one step back18const testBufferNotRead = async (t, fdNumber, all) => {19 const subprocess = execa('max-buffer.js', [`${fdNumber}`], {...fullStdio, buffer: false, all});Split files (#837)ehmickybefore adoption672c2d7
lines 20–22why, one step back20 await t.notThrowsAsync(subprocess);21};22Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 23–26why, one step back23test('Subprocess buffers stdout, which does not prevent exit if not read and buffer is false', testBufferNotRead, 1, false);24test('Subprocess buffers stderr, which does not prevent exit if not read and buffer is false', testBufferNotRead, 2, false);25test('Subprocess buffers stdio[*], which does not prevent exit if not read and buffer is false', testBufferNotRead, 3, false);26test('Subprocess buffers all, which does not prevent exit if not read and buffer is false', testBufferNotRead, 1, true);Split files (#837)ehmickybefore adoption672c2d7
line 27why, one step back27Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 28–30why, one step back28const testBufferRead = async (t, fdNumber, all) => {29 const subprocess = execa('max-buffer.js', [`${fdNumber}`], {...fullStdio, buffer: false, all});30 const stream = all ? subprocess.all : subprocess.stdio[fdNumber];Split files (#837)ehmickybefore adoption672c2d7
lines 31–34why, one step back31 stream.resume();32 await t.notThrowsAsync(subprocess);33};34Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 35–38why, one step back35test('Subprocess buffers stdout, which does not prevent exit if read and buffer is false', testBufferRead, 1, false);36test('Subprocess buffers stderr, which does not prevent exit if read and buffer is false', testBufferRead, 2, false);37test('Subprocess buffers stdio[*], which does not prevent exit if read and buffer is false', testBufferRead, 3, false);38test('Subprocess buffers all, which does not prevent exit if read and buffer is false', testBufferRead, 1, true);Split files (#837)ehmickybefore adoption672c2d7
line 39why, one step back39Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 40why, one step back40const testBufferExit = async (t, fdNumber, fixtureName, reject) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 41why, one step back41 const subprocess = execa(fixtureName, [`${fdNumber}`], {...fullStdio, reject});Split files (#837)ehmickybefore adoption672c2d7
line 42why, one step back42 await setTimeout(100);Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 43why, one step back43 const {stdio} = await subprocess;Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 44why, one step back44 t.is(stdio[fdNumber], 'foobar');Split files (#837)ehmickybefore adoption672c2d7
lines 45–46why, one step back45};46Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 47–55why, one step back47test('Subprocess buffers stdout before it is read', testBufferExit, 1, 'noop-delay.js', true);48test('Subprocess buffers stderr before it is read', testBufferExit, 2, 'noop-delay.js', true);49test('Subprocess buffers stdio[*] before it is read', testBufferExit, 3, 'noop-delay.js', true);50test('Subprocess buffers stdout right away, on successfully exit', testBufferExit, 1, 'noop-fd.js', true);51test('Subprocess buffers stderr right away, on successfully exit', testBufferExit, 2, 'noop-fd.js', true);52test('Subprocess buffers stdio[*] right away, on successfully exit', testBufferExit, 3, 'noop-fd.js', true);53test('Subprocess buffers stdout right away, on failure', testBufferExit, 1, 'noop-fail.js', false);54test('Subprocess buffers stderr right away, on failure', testBufferExit, 2, 'noop-fail.js', false);55test('Subprocess buffers stdio[*] right away, on failure', testBufferExit, 3, 'noop-fail.js', false);Split files (#837)ehmickybefore adoption672c2d7
line 56why, one step back56Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 57why, one step back57const testBufferDirect = async (t, fdNumber) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 58–59why, one step back58 const subprocess = execa('noop-fd.js', [`${fdNumber}`], fullStdio);59 const data = await once(subprocess.stdio[fdNumber], 'data');Split files (#837)ehmickybefore adoption672c2d7
line 60why, one step back60 t.is(data.toString().trim(), 'foobar');Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 61why, one step back61 const result = await subprocess;Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 62why, one step back62 t.is(result.stdio[fdNumber], 'foobar');Split files (#837)ehmickybefore adoption672c2d7
lines 63–64why, one step back63};64Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 65–67why, one step back65test('Subprocess buffers stdout right away, even if directly read', testBufferDirect, 1);66test('Subprocess buffers stderr right away, even if directly read', testBufferDirect, 2);67test('Subprocess buffers stdio[*] right away, even if directly read', testBufferDirect, 3);Split files (#837)ehmickybefore adoption672c2d7
line 68why, one step back68Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 69why, one step back69const testBufferDestroyOnEnd = async (t, fdNumber) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 70–71why, one step back70 const subprocess = execa('noop-fd.js', [`${fdNumber}`], fullStdio);71 const result = await subprocess;Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 72why, one step back72 t.is(result.stdio[fdNumber], 'foobar');Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 73why, one step back73 t.true(subprocess.stdio[fdNumber].destroyed);Split files (#837)ehmickybefore adoption672c2d7
lines 74–75why, one step back74};75Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 76–78why, one step back76test('subprocess.stdout must be read right away', testBufferDestroyOnEnd, 1);77test('subprocess.stderr must be read right away', testBufferDestroyOnEnd, 2);78test('subprocess.stdio[*] must be read right away', testBufferDestroyOnEnd, 3);