Skip to content
Myr

node-stream.js

This file

Path

test/stdio/node-stream.js

327 lines · 15.3 KiB · JavaScript

Last changed by

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

History of this file

Take it

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

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

lines 1–3why, one step back
1import {once} from 'node:events';
2import {createReadStream, createWriteStream} from 'node:fs';3import {readFile, writeFile, rm} from 'node:fs/promises';

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

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

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

line 5why, one step back
5import {text} from 'node:stream/consumers';

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

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

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

line 7why, one step back
7import {callbackify} from 'node:util';

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

lines 8–11why, one step back
8import test from 'ava';
9import tempfile from 'tempfile';10import {execa, execaSync} from '../../index.js';11import {setFixtureDir} from '../helpers/fixtures-dir.js';

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

line 12why, one step back
12import {getStdio} from '../helpers/stdio.js';

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

line 13why, one step back
13import {foobarString} from '../helpers/input.js';

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 14why, one step back
14import {noopReadable, noopWritable, noopDuplex, simpleReadable} from '../helpers/stream.js';

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

lines 15–17why, one step back
15
16setFixtureDir();17

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 18why, one step back
18const testNoFileStreamSync = async (t, fdNumber, stream) => {

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

line 19why, one step back
19 t.throws(() => {

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 20why, one step back
20 execaSync('empty.js', getStdio(fdNumber, stream));

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

line 21why, one step back
21 }, {code: 'ERR_INVALID_ARG_VALUE'});

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

lines 22–23why, one step back
22};
23

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 24–32why, one step back
24test('stdin cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 0, noopReadable());
25test('stdin cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 0, noopDuplex());26test('stdout cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 1, noopWritable());27test('stdout cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 1, noopDuplex());28test('stderr cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 2, noopWritable());29test('stderr cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 2, noopDuplex());30test('stdio[*] cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 3, noopReadable());31test('stdio[*] cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 3, noopWritable());32test('stdio[*] cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 3, noopDuplex());

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

lines 33–34why, one step back
33
34test('input can be a Node.js Readable without a file descriptor', async t => {

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 35–36why, one step back
35 const {stdout} = await execa('stdin.js', {input: simpleReadable()});
36 t.is(stdout, foobarString);

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

lines 37–38why, one step back
37});
38

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

lines 39–40why, one step back
39test('input cannot be a Node.js Readable without a file descriptor - sync', t => {
40 t.throws(() => {

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

line 41why, one step back
41 execaSync('empty.js', {input: simpleReadable()});

Improve validation of `execaSync()` `stdio` option (#941)ehmickybefore adoptioncc565f9

line 42why, one step back
42 }, {message: 'The `input` option cannot be a Node.js stream with synchronous methods.'});

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

lines 43–44why, one step back
43});
44

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

lines 45–46why, one step back
45const testNoFileStream = async (t, fdNumber, stream) => {
46 await t.throwsAsync(execa('empty.js', getStdio(fdNumber, stream)), {code: 'ERR_INVALID_ARG_VALUE'});

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

lines 47–48why, one step back
47};
48

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 49–57why, one step back
49test('stdin cannot be a Node.js Readable without a file descriptor', testNoFileStream, 0, noopReadable());
50test('stdin cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 0, noopDuplex());51test('stdout cannot be a Node.js Writable without a file descriptor', testNoFileStream, 1, noopWritable());52test('stdout cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 1, noopDuplex());53test('stderr cannot be a Node.js Writable without a file descriptor', testNoFileStream, 2, noopWritable());54test('stderr cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 2, noopDuplex());55test('stdio[*] cannot be a Node.js Readable without a file descriptor', testNoFileStream, 3, noopReadable());56test('stdio[*] cannot be a Node.js Writable without a file descriptor', testNoFileStream, 3, noopWritable());57test('stdio[*] cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 3, noopDuplex());

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

line 58why, one step back
58

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 59why, one step back
59const createFileReadStream = async () => {

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

lines 60–63why, one step back
60 const filePath = tempfile();
61 await writeFile(filePath, 'foobar');62 const stream = createReadStream(filePath);63 await once(stream, 'open');

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 64–65why, one step back
64 return {stream, filePath};
65};

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

line 66why, one step back
66

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 67–73why, one step back
67const createFileWriteStream = async () => {
68 const filePath = tempfile();69 const stream = createWriteStream(filePath);70 await once(stream, 'open');71 return {stream, filePath};72};73

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 74why, one step back
74const assertFileStreamError = async (t, subprocess, stream, filePath) => {

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 75–76why, one step back
75 const cause = new Error('test');
76 stream.destroy(cause);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 77why, one step back
77

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 78–79why, one step back
78 const error = await t.throwsAsync(subprocess);
79 t.is(error.cause, cause);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 80–85why, one step back
80 t.is(error.exitCode, 0);
81 t.is(error.signal, undefined);8283 await rm(filePath);84};85

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 86why, one step back
86const testFileReadable = async (t, fdNumber, execaMethod) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 87–88why, one step back
87 const {stream, filePath} = await createFileReadStream();
88

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

lines 89–90why, one step back
89 const fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;
90 const {stdout} = await execaMethod('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));

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

lines 91–95why, one step back
91 t.is(stdout, 'foobar');
9293 await rm(filePath);94};95

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

lines 96–100why, one step back
96test('input can be a Node.js Readable with a file descriptor', testFileReadable, 'input', execa);
97test('stdin can be a Node.js Readable with a file descriptor', testFileReadable, 0, execa);98test('stdio[*] can be a Node.js Readable with a file descriptor', testFileReadable, 3, execa);99test('stdin can be a Node.js Readable with a file descriptor - sync', testFileReadable, 0, execaSync);100test('stdio[*] can be a Node.js Readable with a file descriptor - sync', testFileReadable, 3, execaSync);

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

line 101why, one step back
101

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 102why, one step back
102const testFileReadableError = async (t, fdNumber) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 103–104why, one step back
103 const {stream, filePath} = await createFileReadStream();
104

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 105why, one step back
105 const fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 106why, one step back
106 const subprocess = execa('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 107why, one step back
107

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 108why, one step back
108 await assertFileStreamError(t, subprocess, stream, filePath);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

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

Fix CI tests (#827)ehmickybefore adoption9435a34

lines 111–113why, one step back
111test.serial('input handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 'input');
112test.serial('stdin handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 0);113test.serial('stdio[*] handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 3);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 114why, one step back
114

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 115why, one step back
115const testFileReadableOpen = async (t, fdNumber, useSingle, execaMethod) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 116–119why, one step back
116 const {stream, filePath} = await createFileReadStream();
117 t.deepEqual(stream.eventNames(), []);118119 const stdioOption = useSingle ? stream : [stream, 'pipe'];

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 120why, one step back
120 await execaMethod('empty.js', getStdio(fdNumber, stdioOption));

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 121why, one step back
121

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 122why, one step back
122 t.is(stream.readable, useSingle && fdNumber !== 'input');

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 123–134why, one step back
123 t.deepEqual(stream.eventNames(), []);
124125 await rm(filePath);126};127128test('input closes a Node.js Readable with a file descriptor', testFileReadableOpen, 'input', true, execa);129test('stdin leaves open a single Node.js Readable with a file descriptor', testFileReadableOpen, 0, true, execa);130test('stdin closes a combined Node.js Readable with a file descriptor', testFileReadableOpen, 0, false, execa);131test('stdio[*] leaves open a single Node.js Readable with a file descriptor', testFileReadableOpen, 3, true, execa);132test('stdin leaves open a single Node.js Readable with a file descriptor - sync', testFileReadableOpen, 0, true, execaSync);133test('stdio[*] leaves open a single Node.js Readable with a file descriptor - sync', testFileReadableOpen, 3, true, execaSync);134

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 135why, one step back
135const testFileWritable = async (t, fdNumber, execaMethod) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 136why, one step back
136 const {stream, filePath} = await createFileWriteStream();

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

line 137why, one step back
137

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 138why, one step back
138 await execaMethod('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, stream));

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

line 139why, one step back
139 t.is(await readFile(filePath, 'utf8'), 'foobar');

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

lines 140–143why, one step back
140
141 await rm(filePath);142};143

Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf

lines 144–149why, one step back
144test('stdout can be a Node.js Writable with a file descriptor', testFileWritable, 1, execa);
145test('stderr can be a Node.js Writable with a file descriptor', testFileWritable, 2, execa);146test('stdio[*] can be a Node.js Writable with a file descriptor', testFileWritable, 3, execa);147test('stdout can be a Node.js Writable with a file descriptor - sync', testFileWritable, 1, execaSync);148test('stderr can be a Node.js Writable with a file descriptor - sync', testFileWritable, 2, execaSync);149test('stdio[*] can be a Node.js Writable with a file descriptor - sync', testFileWritable, 3, execaSync);

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

line 150why, one step back
150

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 151why, one step back
151const testFileWritableError = async (t, fdNumber) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 152–153why, one step back
152 const {stream, filePath} = await createFileWriteStream();
153

Fix using both `encoding: 'utf16le'` and `lines`/`verbose` options (#931)ehmickybefore adoptiona480e1d

line 154why, one step back
154 const subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, stream));

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 155why, one step back
155

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 156why, one step back
156 await assertFileStreamError(t, subprocess, stream, filePath);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 157–158why, one step back
157};
158

Fix CI tests (#827)ehmickybefore adoption9435a34

lines 159–161why, one step back
159test.serial('stdout handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 1);
160test.serial('stderr handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 2);161test.serial('stdio[*] handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 3);

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

line 162why, one step back
162

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 163why, one step back
163const testFileWritableOpen = async (t, fdNumber, useSingle, execaMethod) => {

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 164–167why, one step back
164 const {stream, filePath} = await createFileWriteStream();
165 t.deepEqual(stream.eventNames(), []);166167 const stdioOption = useSingle ? stream : [stream, 'pipe'];

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 168why, one step back
168 await execaMethod('empty.js', getStdio(fdNumber, stdioOption));

Fix stream error handling (#826)ehmickybefore adoption35c0fb0

lines 169–185why, one step back
169
170 t.is(stream.writable, useSingle);171 t.deepEqual(stream.eventNames(), []);172173 await rm(filePath);174};175176test('stdout leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 1, true, execa);177test('stdout closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 1, false, execa);178test('stderr leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 2, true, execa);179test('stderr closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 2, false, execa);180test('stdio[*] leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 3, true, execa);181test('stdio[*] closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 3, false, execa);182test('stdout leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 1, true, execaSync);183test('stderr leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 2, true, execaSync);184test('stdio[*] leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 3, true, execaSync);185

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 186why, one step back
186const testLazyFileReadable = async (t, fdNumber) => {

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

lines 187–190why, one step back
187 const filePath = tempfile();
188 await writeFile(filePath, 'foobar');189 const stream = createReadStream(filePath);190

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 191why, one step back
191 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));

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

lines 192–196why, one step back
192 t.is(stdout, 'foobar');
193194 await rm(filePath);195};196

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

lines 197–198why, one step back
197test('stdin can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 0);
198test('stdio[*] can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 3);

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

line 199why, one step back
199

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 200–208why, one step back
200const testLazyFileReadableSync = (t, fdNumber) => {
201 t.throws(() => {202 execaSync('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopReadable(), 'pipe']));203 }, {message: /cannot both be an array and include a stream/});204};205206test('stdin cannot be [Readable, "pipe"] without a file descriptor, sync', testLazyFileReadableSync, 0);207test('stdio[*] cannot be [Readable, "pipe"] without a file descriptor, sync', testLazyFileReadableSync, 3);208

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 209why, one step back
209const testLazyFileWritable = async (t, fdNumber) => {

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

lines 210–212why, one step back
210 const filePath = tempfile();
211 const stream = createWriteStream(filePath);212

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 213why, one step back
213 await execa('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, [stream, 'pipe']));

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

line 214why, one step back
214 t.is(await readFile(filePath, 'utf8'), 'foobar');

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

lines 215–218why, one step back
215
216 await rm(filePath);217};218

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

lines 219–221why, one step back
219test('stdout can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 1);
220test('stderr can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 2);221test('stdio[*] can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 3);

Add support for `std*: ['pipe', 'inherit']` with `execaSync()` (#954)ehmickybefore adoptionc15edbc

lines 222–231why, one step back
222
223const testLazyFileWritableSync = (t, fdNumber) => {224 t.throws(() => {225 execaSync('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopWritable(), 'pipe']));226 }, {message: /cannot both be an array and include a stream/});227};228229test('stdout cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 1);230test('stderr cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 2);231test('stdio[*] cannot be [Writable, "pipe"] without a file descriptor, sync', testLazyFileWritableSync, 3);

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

line 232why, one step back
232

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 233why, one step back
233test('Waits for custom streams destroy on subprocess errors', async t => {

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

lines 234–236why, one step back
234 let waitedForDestroy = false;
235 const stream = new Writable({236 destroy: callbackify(async error => {

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

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

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

lines 238–241why, one step back
238 waitedForDestroy = true;
239 return error;240 }),241 });

Improve process failure logic (#807)ehmickybefore adoption8ff263c

line 242why, one step back
242 const {timedOut} = await t.throwsAsync(execa('forever.js', {stdout: [stream, 'pipe'], timeout: 1}));

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

lines 243–244why, one step back
243 t.true(timedOut);
244 t.true(waitedForDestroy);

Improve process failure logic (#807)ehmickybefore adoption8ff263c

lines 245–246why, one step back
245});
246

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 247why, one step back
247test('Handles custom streams destroy errors on subprocess success', async t => {

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 248why, one step back
248 const cause = new Error('test');

Improve process failure logic (#807)ehmickybefore adoption8ff263c

lines 249–250why, one step back
249 const stream = new Writable({
250 destroy(destroyError, done) {

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 251why, one step back
251 done(destroyError ?? cause);

Improve process failure logic (#807)ehmickybefore adoption8ff263c

lines 252–253why, one step back
252 },
253 });

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 254–255why, one step back
254 const error = await t.throwsAsync(execa('empty.js', {stdout: [stream, 'pipe']}));
255 t.is(error.cause, cause);

Wait for streams completion on errors (#722)ehmickybefore adoption195369f

line 256why, one step back
256});

Destroy internal streams when process exits early (#770)ehmickybefore adoption8db0b09

lines 257–262why, one step back
257
258const testStreamEarlyExit = async (t, stream, streamName) => {259 await t.throwsAsync(execa('noop.js', {[streamName]: [stream, 'pipe'], uid: -1}));260 t.true(stream.destroyed);261};262

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 263–264why, one step back
263test('Input streams are canceled on early subprocess exit', testStreamEarlyExit, noopReadable(), 'stdin');
264test('Output streams are canceled on early subprocess exit', testStreamEarlyExit, noopWritable(), 'stdout');

Improve stream cleanup and termination logic (#775)ehmickybefore adoption5aa90bd

line 265why, one step back
265

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 266why, one step back
266const testInputDuplexStream = async (t, fdNumber) => {

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 267–268why, one step back
267 const stream = new PassThrough();
268 stream.end(foobarString);

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 269why, one step back
269 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 270–275why, one step back
270 t.is(stdout, foobarString);
271};272273test('Can pass Duplex streams to stdin', testInputDuplexStream, 0);274test('Can pass Duplex streams to input stdio[*]', testInputDuplexStream, 3);275

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 276why, one step back
276const testOutputDuplexStream = async (t, fdNumber) => {

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 277–279why, one step back
277 const stream = new PassThrough();
278 const [output] = await Promise.all([279 text(stream),

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 280why, one step back
280 execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe'])),

Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d

lines 281–287why, one step back
281 ]);
282 t.is(output, foobarString);283};284285test('Can pass Duplex streams to stdout', testOutputDuplexStream, 1);286test('Can pass Duplex streams to stderr', testOutputDuplexStream, 2);287test('Can pass Duplex streams to output stdio[*]', testOutputDuplexStream, 3);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 288–292why, one step back
288
289const testInputStreamAbort = async (t, fdNumber) => {290 const stream = new PassThrough();291 stream.destroy();292

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 293–295why, one step back
293 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));
294 await subprocess;295 t.true(subprocess.stdio[fdNumber].writableEnded);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 296–297why, one step back
296};
297

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 298–299why, one step back
298test('subprocess.stdin is ended when an input stream aborts', testInputStreamAbort, 0);
299test('subprocess.stdio[*] is ended when an input stream aborts', testInputStreamAbort, 3);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 300–302why, one step back
300
301const testInputStreamError = async (t, fdNumber) => {302 const stream = new PassThrough();

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 303–304why, one step back
303 const cause = new Error(foobarString);
304 stream.destroy(cause);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

line 305why, one step back
305

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 306why, one step back
306 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 307why, one step back
307 t.like(await t.throwsAsync(subprocess), {cause});

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 308why, one step back
308 t.true(subprocess.stdio[fdNumber].writableEnded);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 309–310why, one step back
309};
310

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 311–312why, one step back
311test('subprocess.stdin is ended when an input stream errors', testInputStreamError, 0);
312test('subprocess.stdio[*] is ended when an input stream errors', testInputStreamError, 3);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 313–315why, one step back
313
314const testOutputStreamError = async (t, fdNumber) => {315 const stream = new PassThrough();

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

lines 316–317why, one step back
316 const cause = new Error(foobarString);
317 stream.destroy(cause);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

line 318why, one step back
318

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 319why, one step back
319 const subprocess = execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 320why, one step back
320 t.like(await t.throwsAsync(subprocess), {cause});

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 321–322why, one step back
321 t.true(subprocess.stdio[fdNumber].readableAborted);
322 t.is(subprocess.stdio[fdNumber].errored, null);

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

lines 323–324why, one step back
323};
324

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 325–327why, one step back
325test('subprocess.stdout is aborted when an output stream errors', testOutputStreamError, 1);
326test('subprocess.stderr is aborted when an output stream errors', testOutputStreamError, 2);327test('subprocess.stdio[*] is aborted when an output stream errors', testOutputStreamError, 3);