Skip to content
Myr

stream.js

This file

Path

test/stream.js

336 lines · 15.8 KiB · JavaScript

Last changed by

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

History of this file

Take it

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

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

line 1why, one step back
1import {Buffer} from 'node:buffer';

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

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

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

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

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

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

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 5–6why, one step back
5import test from 'ava';
6import getStream from 'get-stream';

Refactor tests (#628)ehmickybefore adoption30ecc81

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

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

lines 8–9why, one step back
8import {setFixtureDir} from './helpers/fixtures-dir.js';
9import {fullStdio, getStdio} from './helpers/stdio.js';

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 10why, one step back
10

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

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

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 12why, one step back
12

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 13–14why, one step back
13const foobarString = 'foobar';
14

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 15why, one step back
15test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {

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

line 16why, one step back
16 const {all} = await execa('noop-132.js', {all: true});

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 17–20why, one step back
17 t.is(all, '132');
18});1920test('result.all is undefined unless opts.all is true', async t => {

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

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

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 22–24why, one step back
22 t.is(all, undefined);
23});24

Refactor tests (#628)ehmickybefore adoption30ecc81

lines 25–26why, one step back
25test('result.all is undefined if ignored', async t => {
26 const {all} = await execa('noop.js', {stdio: 'ignore', all: true});

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 27–29why, one step back
27 t.is(all, undefined);
28});29

Improve performance of `childProcess.all` when `stdout` or `stderr` is `ignore` (#646)ehmickybefore adoption249e7c4

line 30why, one step back
30const testAllIgnore = async (t, streamName, otherStreamName) => {

Fix `all` option combined with `ignore` (#703)ehmickybefore adoption7707fc7

lines 31–39why, one step back
31 const childProcess = execa('noop-both.js', {[otherStreamName]: 'ignore', all: true});
32 t.is(childProcess[otherStreamName], null);33 t.not(childProcess[streamName], null);34 t.not(childProcess.all, null);3536 const result = await childProcess;37 t.is(result[otherStreamName], undefined);38 t.is(result[streamName], 'foobar');39 t.is(result.all, 'foobar');

Improve performance of `childProcess.all` when `stdout` or `stderr` is `ignore` (#646)ehmickybefore adoption249e7c4

lines 40–43why, one step back
40};
4142test('can use all: true with stdout: ignore', testAllIgnore, 'stderr', 'stdout');43test('can use all: true with stderr: ignore', testAllIgnore, 'stdout', 'stderr');

Fix `all` option combined with `ignore` (#703)ehmickybefore adoption7707fc7

lines 44–55why, one step back
44
45test('can use all: true with stdout: ignore + stderr: ignore', async t => {46 const childProcess = execa('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});47 t.is(childProcess.stdout, null);48 t.is(childProcess.stderr, null);49 t.is(childProcess.all, undefined);5051 const {stdout, stderr, all} = await childProcess;52 t.is(stdout, undefined);53 t.is(stderr, undefined);54 t.is(all, undefined);55});

Improve performance of `childProcess.all` when `stdout` or `stderr` is `ignore` (#646)ehmickybefore adoption249e7c4

line 56why, one step back
56

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

lines 57–59why, one step back
57const testIgnore = async (t, index, execaMethod) => {
58 const result = await execaMethod('noop.js', getStdio(index, 'ignore'));59 t.is(result.stdio[index], undefined);

Allow `stdin` to be a sync/async iterable (#604)ehmickybefore adoptionec380db

lines 60–61why, one step back
60};
61

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

lines 62–67why, one step back
62test('stdout is undefined if ignored', testIgnore, 1, execa);
63test('stderr is undefined if ignored', testIgnore, 2, execa);64test('stdio[*] is undefined if ignored', testIgnore, 3, execa);65test('stdout is undefined if ignored - sync', testIgnore, 1, execaSync);66test('stderr is undefined if ignored - sync', testIgnore, 2, execaSync);67test('stdio[*] is undefined if ignored - sync', testIgnore, 3, execaSync);

Allow `stdin` to be a sync/async iterable (#604)ehmickybefore adoptionec380db

line 68why, one step back
68

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 69–71why, one step back
69const getFirstDataEvent = async stream => {
70 const [output] = await once(stream, 'data');71 return output.toString();

Add tests related to the `buffer` option (#692)ehmickybefore adoption1825aea

lines 72–73why, one step back
72};
73

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 74–78why, one step back
74// eslint-disable-next-line max-params
75const testIterationBuffer = async (t, index, buffer, useDataEvents, all) => {76 const subprocess = execa('noop-fd.js', [`${index}`, foobarString], {...fullStdio, buffer, all});77 const getOutput = useDataEvents ? getFirstDataEvent : getStream;78 const [result, output, allOutput] = await Promise.all([

Add tests related to the `buffer` option (#692)ehmickybefore adoption1825aea

line 79why, one step back
79 subprocess,

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 80–81why, one step back
80 getOutput(subprocess.stdio[index]),
81 all ? getOutput(subprocess.all) : undefined,

Add tests related to the `buffer` option (#692)ehmickybefore adoption1825aea

line 82why, one step back
82 ]);

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 83–93why, one step back
83
84 const expectedProcessResult = buffer ? foobarString : undefined;85 const expectedOutput = !buffer || useDataEvents ? foobarString : '';8687 t.is(result.stdio[index], expectedProcessResult);88 t.is(output, expectedOutput);8990 if (all) {91 t.is(result.all, expectedProcessResult);92 t.is(allOutput, expectedOutput);93 }

Add tests related to the `buffer` option (#692)ehmickybefore adoption1825aea

lines 94–95why, one step back
94};
95

Add more tests for `result.all` and `childProcess.all` (#704)ehmickybefore adoption6bbd265

lines 96–111why, one step back
96test('Can iterate stdout when `buffer` set to `false`', testIterationBuffer, 1, false, false, false);
97test('Can iterate stderr when `buffer` set to `false`', testIterationBuffer, 2, false, false, false);98test('Can iterate stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, false, false);99test('Can iterate all when `buffer` set to `false`', testIterationBuffer, 1, false, false, true);100test('Cannot iterate stdout when `buffer` set to `true`', testIterationBuffer, 1, true, false, false);101test('Cannot iterate stderr when `buffer` set to `true`', testIterationBuffer, 2, true, false, false);102test('Cannot iterate stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, false, false);103test('Cannot iterate all when `buffer` set to `true`', testIterationBuffer, 1, true, false, true);104test('Can listen to `data` events on stdout when `buffer` set to `false`', testIterationBuffer, 1, false, true, false);105test('Can listen to `data` events on stderr when `buffer` set to `false`', testIterationBuffer, 2, false, true, false);106test('Can listen to `data` events on stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, true, false);107test('Can listen to `data` events on all when `buffer` set to `false`', testIterationBuffer, 1, false, true, true);108test('Can listen to `data` events on stdout when `buffer` set to `true`', testIterationBuffer, 1, true, true, false);109test('Can listen to `data` events on stderr when `buffer` set to `true`', testIterationBuffer, 2, true, true, false);110test('Can listen to `data` events on stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, true, false);111test('Can listen to `data` events on all when `buffer` set to `true`', testIterationBuffer, 1, true, true, true);

Add tests related to the `buffer` option (#692)ehmickybefore adoption1825aea

line 112why, one step back
112

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

lines 113–128why, one step back
113const maxBuffer = 10;
114115const testMaxBufferSuccess = async (t, index, all) => {116 await t.notThrowsAsync(execa('max-buffer.js', [`${index}`, `${maxBuffer}`], {...fullStdio, maxBuffer, all}));117};118119test('maxBuffer does not affect stdout if too high', testMaxBufferSuccess, 1, false);120test('maxBuffer does not affect stderr if too high', testMaxBufferSuccess, 2, false);121test('maxBuffer does not affect stdio[*] if too high', testMaxBufferSuccess, 3, false);122test('maxBuffer does not affect all if too high', testMaxBufferSuccess, 1, true);123124const testMaxBufferLimit = async (t, index, all) => {125 const length = all ? maxBuffer * 2 : maxBuffer;126 const result = await t.throwsAsync(127 execa('max-buffer.js', [`${index}`, `${length + 1}`], {...fullStdio, maxBuffer, all}),128 {message: /maxBuffer exceeded/},

Support file path and URL types in the `stdout` and `stderr` options (#621)ehmickybefore adoptionb369efe

line 129why, one step back
129 );

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

line 130why, one step back
130 t.is(all ? result.all : result.stdio[index], '.'.repeat(length));

Support file path and URL types in the `stdout` and `stderr` options (#621)ehmickybefore adoptionb369efe

line 131why, one step back
131};

Allow `stdin` to be a file URL (#610)ehmickybefore adoptiond37a0f6

line 132why, one step back
132

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

lines 133–136why, one step back
133test('maxBuffer affects stdout', testMaxBufferLimit, 1, false);
134test('maxBuffer affects stderr', testMaxBufferLimit, 2, false);135test('maxBuffer affects stdio[*]', testMaxBufferLimit, 3, false);136test('maxBuffer affects all', testMaxBufferLimit, 1, true);

Allow `stdin` to be a file path (#614)ehmickybefore adoptionf1069b0

line 137why, one step back
137

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

lines 138–140why, one step back
138const testMaxBufferEncoding = async (t, index) => {
139 const result = await t.throwsAsync(140 execa('max-buffer.js', [`${index}`, `${maxBuffer + 1}`], {...fullStdio, maxBuffer, encoding: 'buffer'}),

Fix `error.stdout|stderr|all` type when `encoding` option is used (#652)ehmickybefore adoptioncff6847

line 141why, one step back
141 );

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

lines 142–145why, one step back
142 const stream = result.stdio[index];
143 t.true(stream instanceof Uint8Array);144 t.is(Buffer.from(stream).toString(), '.'.repeat(maxBuffer));145};

Fix `error.stdout|stderr|all` type when `encoding` option is used (#652)ehmickybefore adoptioncff6847

line 146why, one step back
146

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

lines 147–151why, one step back
147test('maxBuffer works with encoding buffer and stdout', testMaxBufferEncoding, 1);
148test('maxBuffer works with encoding buffer and stderr', testMaxBufferEncoding, 2);149test('maxBuffer works with encoding buffer and stdio[*]', testMaxBufferEncoding, 3);150151const testMaxBufferHex = async (t, index) => {

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

line 152why, one step back
152 const halfMaxBuffer = maxBuffer / 2;

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

line 153why, one step back
153 const {stdio} = await t.throwsAsync(

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

line 154why, one step back
154 execa('max-buffer.js', [`${index}`, `${halfMaxBuffer + 1}`], {...fullStdio, maxBuffer, encoding: 'hex'}),

Fix `error.stdout|stderr|all` type when `encoding` option is used (#652)ehmickybefore adoptioncff6847

line 155why, one step back
155 );

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

line 156why, one step back
156 t.is(stdio[index], Buffer.from('.'.repeat(halfMaxBuffer)).toString('hex'));

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

line 157why, one step back
157};

Fix `error.stdout|stderr|all` type when `encoding` option is used (#652)ehmickybefore adoptioncff6847

line 158why, one step back
158

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

lines 159–164why, one step back
159test('maxBuffer works with other encodings and stdout', testMaxBufferHex, 1);
160test('maxBuffer works with other encodings and stderr', testMaxBufferHex, 2);161test('maxBuffer works with other encodings and stdio[*]', testMaxBufferHex, 3);162163const testNoMaxBuffer = async (t, index) => {164 const subprocess = execa('max-buffer.js', [`${index}`, `${maxBuffer}`], {...fullStdio, buffer: false});

Refactor tests (#628)ehmickybefore adoption30ecc81

line 165why, one step back
165 const [result, output] = await Promise.all([

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

lines 166–167why, one step back
166 subprocess,
167 getStream(subprocess.stdio[index]),

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 168why, one step back
168 ]);

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

lines 169–170why, one step back
169 t.is(result.stdio[index], undefined);
170 t.is(output, '.'.repeat(maxBuffer));

Refactor tests (#628)ehmickybefore adoption30ecc81

line 171why, one step back
171};

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 172why, one step back
172

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

lines 173–175why, one step back
173test('do not buffer stdout when `buffer` set to `false`', testNoMaxBuffer, 1);
174test('do not buffer stderr when `buffer` set to `false`', testNoMaxBuffer, 2);175test('do not buffer stdio[*] when `buffer` set to `false`', testNoMaxBuffer, 3);

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 176why, one step back
176

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

lines 177–186why, one step back
177const testNoMaxBufferOption = async (t, index) => {
178 const length = maxBuffer + 1;179 const subprocess = execa('max-buffer.js', [`${index}`, `${length}`], {...fullStdio, maxBuffer, buffer: false});180 const [result, output] = await Promise.all([181 subprocess,182 getStream(subprocess.stdio[index]),183 ]);184 t.is(result.stdio[index], undefined);185 t.is(output, '.'.repeat(length));186};

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 187why, one step back
187

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

lines 188–193why, one step back
188test('do not hit maxBuffer when `buffer` is `false` with stdout', testNoMaxBufferOption, 1);
189test('do not hit maxBuffer when `buffer` is `false` with stderr', testNoMaxBufferOption, 2);190test('do not hit maxBuffer when `buffer` is `false` with stdio[*]', testNoMaxBufferOption, 3);191192const testMaxBufferAbort = async (t, index) => {193 const childProcess = execa('max-buffer.js', [`${index}`, `${maxBuffer + 1}`], {...fullStdio, maxBuffer});

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

lines 194–195why, one step back
194 await Promise.all([
195 t.throwsAsync(childProcess, {message: /maxBuffer exceeded/}),

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

line 196why, one step back
196 t.throwsAsync(getStream(childProcess.stdio[index]), {code: 'ABORT_ERR'}),

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 197why, one step back
197 ]);

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

line 198why, one step back
198};

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 199why, one step back
199

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

lines 200–203why, one step back
200test('abort stream when hitting maxBuffer with stdout', testMaxBufferAbort, 1);
201test('abort stream when hitting maxBuffer with stderr', testMaxBufferAbort, 2);202test('abort stream when hitting maxBuffer with stdio[*]', testMaxBufferAbort, 3);203

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 204why, one step back
204test('buffer: false > promise resolves', async t => {

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

line 205why, one step back
205 await t.notThrowsAsync(execa('noop.js', {buffer: false}));

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 206–207why, one step back
206});
207

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

lines 208–210why, one step back
208test('buffer: false > promise rejects when process returns non-zero', async t => {
209 const {exitCode} = await t.throwsAsync(execa('fail.js', {buffer: false}));210 t.is(exitCode, 2);

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

lines 211–212why, one step back
211});
212

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

lines 213–219why, one step back
213const testStreamEnd = async (t, index, buffer) => {
214 const subprocess = execa('wrong command', {...fullStdio, buffer});215 await Promise.all([216 t.throwsAsync(subprocess, {message: /wrong command/}),217 once(subprocess.stdio[index], 'end'),218 ]);219};

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 220why, one step back
220

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

lines 221–226why, one step back
221test('buffer: false > emits end event on stdout when promise is rejected', testStreamEnd, 1, false);
222test('buffer: false > emits end event on stderr when promise is rejected', testStreamEnd, 2, false);223test('buffer: false > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, false);224test('buffer: true > emits end event on stdout when promise is rejected', testStreamEnd, 1, true);225test('buffer: true > emits end event on stderr when promise is rejected', testStreamEnd, 2, true);226test('buffer: true > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, true);

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 227why, one step back
227

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

lines 228–230why, one step back
228const testBufferIgnore = async (t, index, all) => {
229 await t.notThrowsAsync(execa('max-buffer.js', [`${index}`], {...getStdio(index, 'ignore'), buffer: false, all}));230};

Emit `end` event on streams when process fails (#518)ehmickybefore adoption30c7a7a

line 231why, one step back
231

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

lines 232–234why, one step back
232test('Process buffers stdout, which does not prevent exit if ignored', testBufferIgnore, 1, false);
233test('Process buffers stderr, which does not prevent exit if ignored', testBufferIgnore, 2, false);234test('Process buffers all, which does not prevent exit if ignored', testBufferIgnore, 1, true);

Add two unit tests covering the `all` option (#382)ehmickybefore adoption8b568f4

line 235why, one step back
235

Fix randomly failing tests (#672)ehmickybefore adoption282d189

lines 236–238why, one step back
236// This specific behavior does not happen on Windows.
237// Also, on macOS, it randomly happens, which would make those tests randomly fail.238if (process.platform === 'linux') {

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

lines 239–240why, one step back
239 const testBufferNotRead = async (t, index, all) => {
240 const {timedOut} = await t.throwsAsync(execa('max-buffer.js', [`${index}`], {...fullStdio, buffer: false, all, timeout: 1e3}));

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 241why, one step back
241 t.true(timedOut);

Fix randomly failing tests (#672)ehmickybefore adoption282d189

line 242why, one step back
242 };

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 243why, one step back
243

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

lines 244–247why, one step back
244 test.serial('Process buffers stdout, which prevents exit if not read and buffer is false', testBufferNotRead, 1, false);
245 test.serial('Process buffers stderr, which prevents exit if not read and buffer is false', testBufferNotRead, 2, false);246 test.serial('Process buffers stdio[*], which prevents exit if not read and buffer is false', testBufferNotRead, 3, false);247 test.serial('Process buffers all, which prevents exit if not read and buffer is false', testBufferNotRead, 1, true);

Fix randomly failing tests (#672)ehmickybefore adoption282d189

line 248why, one step back
248

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

lines 249–253why, one step back
249 const testBufferRead = async (t, index, all) => {
250 const subprocess = execa('max-buffer.js', [`${index}`], {...fullStdio, buffer: false, all, timeout: 1e4});251 const stream = all ? subprocess.all : subprocess.stdio[index];252 stream.resume();253 await t.notThrowsAsync(subprocess);

Fix randomly failing tests (#672)ehmickybefore adoption282d189

lines 254–255why, one step back
254 };
255

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

lines 256–259why, one step back
256 test.serial('Process buffers stdout, which does not prevent exit if read and buffer is false', testBufferRead, 1, false);
257 test.serial('Process buffers stderr, which does not prevent exit if read and buffer is false', testBufferRead, 2, false);258 test.serial('Process buffers stdio[*], which does not prevent exit if read and buffer is false', testBufferRead, 3, false);259 test.serial('Process buffers all, which does not prevent exit if read and buffer is false', testBufferRead, 1, true);

Add `error.signalDescription` (#378)ehmickybefore adoptiond8cb08f

line 260why, one step back
260}

Ensure process exits on stream errors (#607)ehmickybefore adoption2f89219

line 261why, one step back
261

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

lines 262–267why, one step back
262const testStreamDestroy = async (t, index) => {
263 const childProcess = execa('forever.js', fullStdio);264 const error = new Error('test');265 childProcess.stdio[index].destroy(error);266 await t.throwsAsync(childProcess, {message: /test/});267};

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

line 268why, one step back
268

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

lines 269–272why, one step back
269test('Destroying stdin should make the process exit', testStreamDestroy, 0);
270test('Destroying stdout should make the process exit', testStreamDestroy, 1);271test('Destroying stderr should make the process exit', testStreamDestroy, 2);272test('Destroying stdio[*] should make the process exit', testStreamDestroy, 3);

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

line 273why, one step back
273

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

lines 274–280why, one step back
274const testStreamError = async (t, index) => {
275 const childProcess = execa('forever.js', fullStdio);276 await setTimeout(0);277 const error = new Error('test');278 childProcess.stdio[index].emit('error', error);279 await t.throwsAsync(childProcess, {message: /test/});280};

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

line 281why, one step back
281

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

lines 282–285why, one step back
282test('Errors on stdin should make the process exit', testStreamError, 0);
283test('Errors on stdout should make the process exit', testStreamError, 1);284test('Errors on stderr should make the process exit', testStreamError, 2);285test('Errors on stdio[*] should make the process exit', testStreamError, 3);

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

line 286why, one step back
286

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

lines 287–290why, one step back
287const testWaitOnStreamEnd = async (t, index) => {
288 const childProcess = execa('stdin-fd.js', [`${index}`], fullStdio);289 await setTimeout(100);290 childProcess.stdio[index].end('foobar');

Add race condition-related tests (#618)ehmickybefore adoptionbea94d6

line 291why, one step back
291 const {stdout} = await childProcess;

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 292why, one step back
292 t.is(stdout, 'foobar');

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

line 293why, one step back
293};

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 294why, one step back
294

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

lines 295–317why, one step back
295test.serial('Process waits on stdin before exiting', testWaitOnStreamEnd, 0);
296test.serial('Process waits on stdio[*] before exiting', testWaitOnStreamEnd, 3);297298const testBufferExit = async (t, index, fixtureName, reject) => {299 const childProcess = execa(fixtureName, [`${index}`], {...fullStdio, reject});300 await setTimeout(100);301 const {stdio} = await childProcess;302 t.is(stdio[index], 'foobar');303};304305test.serial('Process buffers stdout before it is read', testBufferExit, 1, 'noop-delay.js', true);306test.serial('Process buffers stderr before it is read', testBufferExit, 2, 'noop-delay.js', true);307test.serial('Process buffers stdio[*] before it is read', testBufferExit, 3, 'noop-delay.js', true);308test.serial('Process buffers stdout right away, on successfully exit', testBufferExit, 1, 'noop-fd.js', true);309test.serial('Process buffers stderr right away, on successfully exit', testBufferExit, 2, 'noop-fd.js', true);310test.serial('Process buffers stdio[*] right away, on successfully exit', testBufferExit, 3, 'noop-fd.js', true);311test.serial('Process buffers stdout right away, on failure', testBufferExit, 1, 'noop-fail.js', false);312test.serial('Process buffers stderr right away, on failure', testBufferExit, 2, 'noop-fail.js', false);313test.serial('Process buffers stdio[*] right away, on failure', testBufferExit, 3, 'noop-fail.js', false);314315const testBufferDirect = async (t, index) => {316 const childProcess = execa('noop-fd.js', [`${index}`], fullStdio);317 const data = await once(childProcess.stdio[index], 'data');

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 318why, one step back
318 t.is(data.toString().trim(), 'foobar');

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

lines 319–321why, one step back
319 const result = await childProcess;
320 t.is(result.stdio[index], 'foobar');321};

Fix unhandled rejections and missing data (#658)ehmickybefore adoption20b2ee6

line 322why, one step back
322

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

lines 323–336why, one step back
323test('Process buffers stdout right away, even if directly read', testBufferDirect, 1);
324test('Process buffers stderr right away, even if directly read', testBufferDirect, 2);325test('Process buffers stdio[*] right away, even if directly read', testBufferDirect, 3);326327const testBufferDestroyOnEnd = async (t, index) => {328 const childProcess = execa('noop-fd.js', [`${index}`], fullStdio);329 const result = await childProcess;330 t.is(result.stdio[index], 'foobar');331 t.true(childProcess.stdio[index].destroyed);332};333334test('childProcess.stdout must be read right away', testBufferDestroyOnEnd, 1);335test('childProcess.stderr must be read right away', testBufferDestroyOnEnd, 2);336test('childProcess.stdio[*] must be read right away', testBufferDestroyOnEnd, 3);