Skip to content
Myr

stream.js

This file

Path

test/stream.js

367 lines · 17.3 KiB · JavaScript

Last changed by

Prefer `setImmediate()` over `setTimeout()` (#733)ehmickybefore adoption66d12bf

History of this file

Take it

The walk stopped after 200 commits: lines older than 6201405 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';

Upgrade `merge-streams` (#717)ehmickybefore adoption8ef8e90

line 4why, one step back
4import {getDefaultHighWaterMark} from 'node:stream';

Prefer `setImmediate()` over `setTimeout()` (#733)ehmickybefore adoption66d12bf

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

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

Refactor tests (#628)ehmickybefore adoption30ecc81

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

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 11why, one step back
11

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 13why, one step back
13

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 16why, one step back
16test.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 17why, one step back
17 const {all} = await execa('noop-132.js', {all: true});

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

lines 18–21why, one step back
18 t.is(all, '132');
19});2021test('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 22why, one step back
22 const {all} = await execa('noop.js');

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

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

Refactor tests (#628)ehmickybefore adoption30ecc81

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

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

Upgrade `merge-streams` (#717)ehmickybefore adoption8ef8e90

lines 31–41why, one step back
31const testAllProperties = async (t, options) => {
32 const childProcess = execa('empty.js', {...options, all: true});33 t.is(childProcess.all.readableObjectMode, false);34 t.is(childProcess.all.readableHighWaterMark, getDefaultHighWaterMark(false));35 await childProcess;36};3738test('childProcess.all has the right objectMode and highWaterMark - stdout + stderr', testAllProperties, {});39test('childProcess.all has the right objectMode and highWaterMark - stdout only', testAllProperties, {stderr: 'ignore'});40test('childProcess.all has the right objectMode and highWaterMark - stderr only', testAllProperties, {stdout: 'ignore'});41

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

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

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

lines 43–46why, one step back
43 const childProcess = execa('noop-both.js', {[otherStreamName]: 'ignore', all: true});
44 t.is(childProcess[otherStreamName], null);45 t.not(childProcess[streamName], null);46 t.not(childProcess.all, null);

Upgrade `merge-streams` (#717)ehmickybefore adoption8ef8e90

lines 47–48why, one step back
47 t.is(childProcess.all.readableObjectMode, childProcess[streamName].readableObjectMode);
48 t.is(childProcess.all.readableHighWaterMark, childProcess[streamName].readableHighWaterMark);

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

lines 49–53why, one step back
49
50 const result = await childProcess;51 t.is(result[otherStreamName], undefined);52 t.is(result[streamName], 'foobar');53 t.is(result.all, 'foobar');

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

lines 54–57why, one step back
54};
5556test('can use all: true with stdout: ignore', testAllIgnore, 'stderr', 'stdout');57test('can use all: true with stderr: ignore', testAllIgnore, 'stdout', 'stderr');

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

lines 58–69why, one step back
58
59test('can use all: true with stdout: ignore + stderr: ignore', async t => {60 const childProcess = execa('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});61 t.is(childProcess.stdout, null);62 t.is(childProcess.stderr, null);63 t.is(childProcess.all, undefined);6465 const {stdout, stderr, all} = await childProcess;66 t.is(stdout, undefined);67 t.is(stderr, undefined);68 t.is(all, undefined);69});

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

line 70why, one step back
70

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

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

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

lines 74–75why, one step back
74};
75

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

lines 76–81why, one step back
76test('stdout is undefined if ignored', testIgnore, 1, execa);
77test('stderr is undefined if ignored', testIgnore, 2, execa);78test('stdio[*] is undefined if ignored', testIgnore, 3, execa);79test('stdout is undefined if ignored - sync', testIgnore, 1, execaSync);80test('stderr is undefined if ignored - sync', testIgnore, 2, execaSync);81test('stdio[*] is undefined if ignored - sync', testIgnore, 3, execaSync);

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

line 82why, one step back
82

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

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

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

lines 86–87why, one step back
86};
87

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

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

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

line 93why, one step back
93 subprocess,

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

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

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

line 96why, one step back
96 ]);

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

lines 97–107why, one step back
97
98 const expectedProcessResult = buffer ? foobarString : undefined;99 const expectedOutput = !buffer || useDataEvents ? foobarString : '';100101 t.is(result.stdio[index], expectedProcessResult);102 t.is(output, expectedOutput);103104 if (all) {105 t.is(result.all, expectedProcessResult);106 t.is(allOutput, expectedOutput);107 }

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

lines 108–109why, one step back
108};
109

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

lines 110–125why, one step back
110test('Can iterate stdout when `buffer` set to `false`', testIterationBuffer, 1, false, false, false);
111test('Can iterate stderr when `buffer` set to `false`', testIterationBuffer, 2, false, false, false);112test('Can iterate stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, false, false);113test('Can iterate all when `buffer` set to `false`', testIterationBuffer, 1, false, false, true);114test('Cannot iterate stdout when `buffer` set to `true`', testIterationBuffer, 1, true, false, false);115test('Cannot iterate stderr when `buffer` set to `true`', testIterationBuffer, 2, true, false, false);116test('Cannot iterate stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, false, false);117test('Cannot iterate all when `buffer` set to `true`', testIterationBuffer, 1, true, false, true);118test('Can listen to `data` events on stdout when `buffer` set to `false`', testIterationBuffer, 1, false, true, false);119test('Can listen to `data` events on stderr when `buffer` set to `false`', testIterationBuffer, 2, false, true, false);120test('Can listen to `data` events on stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, true, false);121test('Can listen to `data` events on all when `buffer` set to `false`', testIterationBuffer, 1, false, true, true);122test('Can listen to `data` events on stdout when `buffer` set to `true`', testIterationBuffer, 1, true, true, false);123test('Can listen to `data` events on stderr when `buffer` set to `true`', testIterationBuffer, 2, true, true, false);124test('Can listen to `data` events on stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, true, false);125test('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 126why, one step back
126

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

lines 127–137why, one step back
127const maxBuffer = 10;
128129const testMaxBufferSuccess = async (t, index, all) => {130 await t.notThrowsAsync(execa('max-buffer.js', [`${index}`, `${maxBuffer}`], {...fullStdio, maxBuffer, all}));131};132133test('maxBuffer does not affect stdout if too high', testMaxBufferSuccess, 1, false);134test('maxBuffer does not affect stderr if too high', testMaxBufferSuccess, 2, false);135test('maxBuffer does not affect stdio[*] if too high', testMaxBufferSuccess, 3, false);136test('maxBuffer does not affect all if too high', testMaxBufferSuccess, 1, true);137

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 138–146why, one step back
138test('maxBuffer uses killSignal', async t => {
139 const {isTerminated, signal} = await t.throwsAsync(140 execa('noop-forever.js', ['.'.repeat(maxBuffer + 1)], {maxBuffer, killSignal: 'SIGINT'}),141 {message: /maxBuffer exceeded/},142 );143 t.true(isTerminated);144 t.is(signal, 'SIGINT');145});146

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

lines 147–151why, one step back
147const testMaxBufferLimit = async (t, index, all) => {
148 const length = all ? maxBuffer * 2 : maxBuffer;149 const result = await t.throwsAsync(150 execa('max-buffer.js', [`${index}`, `${length + 1}`], {...fullStdio, maxBuffer, all}),151 {message: /maxBuffer exceeded/},

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

line 152why, one step back
152 );

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

line 153why, one step back
153 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 154why, one step back
154};

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

line 155why, one step back
155

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

lines 156–159why, one step back
156test('maxBuffer affects stdout', testMaxBufferLimit, 1, false);
157test('maxBuffer affects stderr', testMaxBufferLimit, 2, false);158test('maxBuffer affects stdio[*]', testMaxBufferLimit, 3, false);159test('maxBuffer affects all', testMaxBufferLimit, 1, true);

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

line 160why, one step back
160

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

lines 161–163why, one step back
161const testMaxBufferEncoding = async (t, index) => {
162 const result = await t.throwsAsync(163 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 164why, one step back
164 );

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

lines 165–168why, one step back
165 const stream = result.stdio[index];
166 t.true(stream instanceof Uint8Array);167 t.is(Buffer.from(stream).toString(), '.'.repeat(maxBuffer));168};

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

line 169why, one step back
169

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

lines 170–174why, one step back
170test('maxBuffer works with encoding buffer and stdout', testMaxBufferEncoding, 1);
171test('maxBuffer works with encoding buffer and stderr', testMaxBufferEncoding, 2);172test('maxBuffer works with encoding buffer and stdio[*]', testMaxBufferEncoding, 3);173174const testMaxBufferHex = async (t, index) => {

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

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

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

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

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

line 177why, one step back
177 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 178why, one step back
178 );

Fix `encoding` option (#696)ehmickybefore adoptionb6f9fa2

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

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

line 180why, one step back
180};

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

line 181why, one step back
181

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

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

Refactor tests (#628)ehmickybefore adoption30ecc81

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

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 191why, one step back
191 ]);

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

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

Refactor tests (#628)ehmickybefore adoption30ecc81

line 194why, one step back
194};

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 195why, one step back
195

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 199why, one step back
199

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

lines 200–209why, one step back
200const testNoMaxBufferOption = async (t, index) => {
201 const length = maxBuffer + 1;202 const subprocess = execa('max-buffer.js', [`${index}`, `${length}`], {...fullStdio, maxBuffer, buffer: false});203 const [result, output] = await Promise.all([204 subprocess,205 getStream(subprocess.stdio[index]),206 ]);207 t.is(result.stdio[index], undefined);208 t.is(output, '.'.repeat(length));209};

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 210why, one step back
210

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

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

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

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

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

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

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

line 220why, one step back
220 ]);

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

line 221why, one step back
221};

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

line 222why, one step back
222

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

lines 223–226why, one step back
223test('abort stream when hitting maxBuffer with stdout', testMaxBufferAbort, 1);
224test('abort stream when hitting maxBuffer with stderr', testMaxBufferAbort, 2);225test('abort stream when hitting maxBuffer with stdio[*]', testMaxBufferAbort, 3);226

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

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

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

lines 229–230why, one step back
229});
230

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

lines 234–235why, one step back
234});
235

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

lines 236–242why, one step back
236const testStreamEnd = async (t, index, buffer) => {
237 const subprocess = execa('wrong command', {...fullStdio, buffer});238 await Promise.all([239 t.throwsAsync(subprocess, {message: /wrong command/}),240 once(subprocess.stdio[index], 'end'),241 ]);242};

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 243why, one step back
243

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

lines 244–249why, one step back
244test('buffer: false > emits end event on stdout when promise is rejected', testStreamEnd, 1, false);
245test('buffer: false > emits end event on stderr when promise is rejected', testStreamEnd, 2, false);246test('buffer: false > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, false);247test('buffer: true > emits end event on stdout when promise is rejected', testStreamEnd, 1, true);248test('buffer: true > emits end event on stderr when promise is rejected', testStreamEnd, 2, true);249test('buffer: true > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, true);

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 250why, one step back
250

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

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

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

line 254why, one step back
254

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 258why, one step back
258

Fix randomly failing tests (#672)ehmickybefore adoption282d189

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

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

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

Fix randomly failing tests (#672)ehmickybefore adoption282d189

line 265why, one step back
265 };

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 266why, one step back
266

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

lines 267–270why, one step back
267 test.serial('Process buffers stdout, which prevents exit if not read and buffer is false', testBufferNotRead, 1, false);
268 test.serial('Process buffers stderr, which prevents exit if not read and buffer is false', testBufferNotRead, 2, false);269 test.serial('Process buffers stdio[*], which prevents exit if not read and buffer is false', testBufferNotRead, 3, false);270 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 271why, one step back
271

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

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

Fix randomly failing tests (#672)ehmickybefore adoption282d189

lines 277–278why, one step back
277 };
278

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

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

Add code comment related to setTimeout().unref (#401)ehmickybefore adoption6201405

line 283why, one step back
283}

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

line 284why, one step back
284

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

lines 285–290why, one step back
285const testStreamDestroy = async (t, index) => {
286 const childProcess = execa('forever.js', fullStdio);287 const error = new Error('test');288 childProcess.stdio[index].destroy(error);289 await t.throwsAsync(childProcess, {message: /test/});290};

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

line 291why, one step back
291

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

lines 292–295why, one step back
292test('Destroying stdin should make the process exit', testStreamDestroy, 0);
293test('Destroying stdout should make the process exit', testStreamDestroy, 1);294test('Destroying stderr should make the process exit', testStreamDestroy, 2);295test('Destroying stdio[*] should make the process exit', testStreamDestroy, 3);

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

line 296why, one step back
296

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

lines 297–298why, one step back
297const testStreamError = async (t, index) => {
298 const childProcess = execa('forever.js', fullStdio);

Prefer `setImmediate()` over `setTimeout()` (#733)ehmickybefore adoption66d12bf

line 299why, one step back
299 await setImmediate();

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

lines 300–303why, one step back
300 const error = new Error('test');
301 childProcess.stdio[index].emit('error', error);302 await t.throwsAsync(childProcess, {message: /test/});303};

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

line 304why, one step back
304

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

lines 305–308why, one step back
305test('Errors on stdin should make the process exit', testStreamError, 0);
306test('Errors on stdout should make the process exit', testStreamError, 1);307test('Errors on stderr should make the process exit', testStreamError, 2);308test('Errors on stdio[*] should make the process exit', testStreamError, 3);

Improve `killSignal` option (#728)ehmickybefore adoptioncf36c1d

lines 309–316why, one step back
309
310test('Errors on streams use killSignal', async t => {311 const childProcess = execa('forever.js', {killSignal: 'SIGINT'});312 childProcess.stdout.destroy(new Error('test'));313 const {isTerminated, signal} = await t.throwsAsync(childProcess, {message: /test/});314 t.true(isTerminated);315 t.is(signal, 'SIGINT');316});

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

line 317why, one step back
317

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

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

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

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

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

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

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

line 324why, one step back
324};

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

line 325why, one step back
325

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

lines 326–348why, one step back
326test.serial('Process waits on stdin before exiting', testWaitOnStreamEnd, 0);
327test.serial('Process waits on stdio[*] before exiting', testWaitOnStreamEnd, 3);328329const testBufferExit = async (t, index, fixtureName, reject) => {330 const childProcess = execa(fixtureName, [`${index}`], {...fullStdio, reject});331 await setTimeout(100);332 const {stdio} = await childProcess;333 t.is(stdio[index], 'foobar');334};335336test.serial('Process buffers stdout before it is read', testBufferExit, 1, 'noop-delay.js', true);337test.serial('Process buffers stderr before it is read', testBufferExit, 2, 'noop-delay.js', true);338test.serial('Process buffers stdio[*] before it is read', testBufferExit, 3, 'noop-delay.js', true);339test.serial('Process buffers stdout right away, on successfully exit', testBufferExit, 1, 'noop-fd.js', true);340test.serial('Process buffers stderr right away, on successfully exit', testBufferExit, 2, 'noop-fd.js', true);341test.serial('Process buffers stdio[*] right away, on successfully exit', testBufferExit, 3, 'noop-fd.js', true);342test.serial('Process buffers stdout right away, on failure', testBufferExit, 1, 'noop-fail.js', false);343test.serial('Process buffers stderr right away, on failure', testBufferExit, 2, 'noop-fail.js', false);344test.serial('Process buffers stdio[*] right away, on failure', testBufferExit, 3, 'noop-fail.js', false);345346const testBufferDirect = async (t, index) => {347 const childProcess = execa('noop-fd.js', [`${index}`], fullStdio);348 const data = await once(childProcess.stdio[index], 'data');

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

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

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

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

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

line 353why, one step back
353

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

lines 354–367why, one step back
354test('Process buffers stdout right away, even if directly read', testBufferDirect, 1);
355test('Process buffers stderr right away, even if directly read', testBufferDirect, 2);356test('Process buffers stdio[*] right away, even if directly read', testBufferDirect, 3);357358const testBufferDestroyOnEnd = async (t, index) => {359 const childProcess = execa('noop-fd.js', [`${index}`], fullStdio);360 const result = await childProcess;361 t.is(result.stdio[index], 'foobar');362 t.true(childProcess.stdio[index].destroyed);363};364365test('childProcess.stdout must be read right away', testBufferDestroyOnEnd, 1);366test('childProcess.stderr must be read right away', testBufferDestroyOnEnd, 2);367test('childProcess.stdio[*] must be read right away', testBufferDestroyOnEnd, 3);