node-stream.js
This file
Path
test/stdio/node-stream.js
309 lines · 14.3 KiB · JavaScript
Last changed by
Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
History of this fileTake it
Refactor tests (#628)ehmickybefore adoption30ecc81
lines 1–3why, one step back1import {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 back4import {Writable, PassThrough} from 'node:stream';Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
line 5why, one step back5import {text} from 'node:stream/consumers';Prefer `setImmediate()` over `setTimeout()` (#733)ehmickybefore adoption66d12bf
line 6why, one step back6import {setImmediate} from 'node:timers/promises';Wait for streams completion on errors (#722)ehmickybefore adoption195369f
line 7why, one step back7import {callbackify} from 'node:util';Refactor tests (#628)ehmickybefore adoption30ecc81
lines 8–11why, one step back8import 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 back12import {getStdio} from '../helpers/stdio.js';Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
line 13why, one step back13import {foobarString} from '../helpers/input.js';Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 14why, one step back14import {noopReadable, noopWritable, noopDuplex, simpleReadable} from '../helpers/stream.js';Refactor tests (#628)ehmickybefore adoption30ecc81
lines 15–17why, one step back1516setFixtureDir();17Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 18why, one step back18const testNoFileStreamSync = async (t, fdNumber, stream) => {Refactor tests (#628)ehmickybefore adoption30ecc81
line 19why, one step back19 t.throws(() => {Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 20why, one step back20 execaSync('empty.js', getStdio(fdNumber, stream));Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
line 21why, one step back21 }, {code: 'ERR_INVALID_ARG_VALUE'});Refactor tests (#628)ehmickybefore adoption30ecc81
lines 22–23why, one step back22};23Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
lines 24–32why, one step back24test('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());Refactor tests (#628)ehmickybefore adoption30ecc81
lines 33–34why, one step back3334test('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 back35 const {stdout} = await execa('stdin.js', {input: simpleReadable()});36 t.is(stdout, foobarString);Refactor tests (#628)ehmickybefore adoption30ecc81
lines 37–38why, one step back37});38Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 39–40why, one step back39test('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 back41 execaSync('empty.js', {input: simpleReadable()});Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 42–44why, one step back42 }, {message: 'The `input` option cannot be a Node.js stream in sync mode.'});43});44Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 45–46why, one step back45const testNoFileStream = async (t, fdNumber, stream) => {46 await t.throwsAsync(execa('empty.js', getStdio(fdNumber, stream)), {code: 'ERR_INVALID_ARG_VALUE'});Refactor tests (#628)ehmickybefore adoption30ecc81
lines 47–48why, one step back47};48Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
lines 49–57why, one step back49test('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());Refactor tests (#628)ehmickybefore adoption30ecc81
line 58why, one step back58Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 59why, one step back59const createFileReadStream = async () => {Refactor tests (#628)ehmickybefore adoption30ecc81
lines 60–63why, one step back60 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 back64 return {stream, filePath};65};Refactor tests (#628)ehmickybefore adoption30ecc81
line 66why, one step back66Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 67–73why, one step back67const createFileWriteStream = async () => {68 const filePath = tempfile();69 const stream = createWriteStream(filePath);70 await once(stream, 'open');71 return {stream, filePath};72};73Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 74why, one step back74const assertFileStreamError = async (t, subprocess, stream, filePath) => {Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 75–76why, one step back75 const cause = new Error('test');76 stream.destroy(cause);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 77why, one step back77Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 78–79why, one step back78 const error = await t.throwsAsync(subprocess);79 t.is(error.cause, cause);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 80–85why, one step back80 t.is(error.exitCode, 0);81 t.is(error.signal, undefined);8283 await rm(filePath);84};85Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 86why, one step back86const testFileReadable = async (t, fdNumber, execaMethod) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 87–88why, one step back87 const {stream, filePath} = await createFileReadStream();88Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
lines 89–90why, one step back89 const fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;90 const {stdout} = await execaMethod('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));Refactor tests (#628)ehmickybefore adoption30ecc81
lines 91–95why, one step back91 t.is(stdout, 'foobar');9293 await rm(filePath);94};95Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 96–100why, one step back96test('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);Refactor tests (#628)ehmickybefore adoption30ecc81
line 101why, one step back101Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 102why, one step back102const testFileReadableError = async (t, fdNumber) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 103–104why, one step back103 const {stream, filePath} = await createFileReadStream();104Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 105why, one step back105 const fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 106why, one step back106 const subprocess = execa('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 107why, one step back107Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 108why, one step back108 await assertFileStreamError(t, subprocess, stream, filePath);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 109–110why, one step back109};110Fix CI tests (#827)ehmickybefore adoption9435a34
lines 111–113why, one step back111test.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 back114Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 115why, one step back115const testFileReadableOpen = async (t, fdNumber, useSingle, execaMethod) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 116–119why, one step back116 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 back120 await execaMethod('empty.js', getStdio(fdNumber, stdioOption));Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 121why, one step back121Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 122why, one step back122 t.is(stream.readable, useSingle && fdNumber !== 'input');Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 123–134why, one step back123 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);134Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 135why, one step back135const testFileWritable = async (t, fdNumber, execaMethod) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 136why, one step back136 const {stream, filePath} = await createFileWriteStream();Refactor tests (#628)ehmickybefore adoption30ecc81
line 137why, one step back137Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 138why, one step back138 await execaMethod('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, stream));Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 139why, one step back139 t.is(await readFile(filePath, 'utf8'), 'foobar');Refactor tests (#628)ehmickybefore adoption30ecc81
lines 140–143why, one step back140141 await rm(filePath);142};143Allow Node.js streams with synchronous methods (#708)ehmickybefore adoption86bdadf
lines 144–149why, one step back144test('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);Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
line 150why, one step back150Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 151why, one step back151const testFileWritableError = async (t, fdNumber) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 152–153why, one step back152 const {stream, filePath} = await createFileWriteStream();153Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 154–155why, one step back154 const subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stream));155 subprocess.stdin.end(foobarString);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 156why, one step back156Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 157why, one step back157 await assertFileStreamError(t, subprocess, stream, filePath);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 158–159why, one step back158};159Fix CI tests (#827)ehmickybefore adoption9435a34
lines 160–162why, one step back160test.serial('stdout handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 1);161test.serial('stderr handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 2);162test.serial('stdio[*] handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 3);Fix stream error handling (#826)ehmickybefore adoption35c0fb0
line 163why, one step back163Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 164why, one step back164const testFileWritableOpen = async (t, fdNumber, useSingle, execaMethod) => {Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 165–168why, one step back165 const {stream, filePath} = await createFileWriteStream();166 t.deepEqual(stream.eventNames(), []);167168 const stdioOption = useSingle ? stream : [stream, 'pipe'];Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 169why, one step back169 await execaMethod('empty.js', getStdio(fdNumber, stdioOption));Fix stream error handling (#826)ehmickybefore adoption35c0fb0
lines 170–186why, one step back170171 t.is(stream.writable, useSingle);172 t.deepEqual(stream.eventNames(), []);173174 await rm(filePath);175};176177test('stdout leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 1, true, execa);178test('stdout closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 1, false, execa);179test('stderr leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 2, true, execa);180test('stderr closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 2, false, execa);181test('stdio[*] leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 3, true, execa);182test('stdio[*] closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 3, false, execa);183test('stdout leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 1, true, execaSync);184test('stderr leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 2, true, execaSync);185test('stdio[*] leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 3, true, execaSync);186Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 187why, one step back187const testLazyFileReadable = async (t, fdNumber) => {Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 188–191why, one step back188 const filePath = tempfile();189 await writeFile(filePath, 'foobar');190 const stream = createReadStream(filePath);191Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 192why, one step back192 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 193–197why, one step back193 t.is(stdout, 'foobar');194195 await rm(filePath);196};197Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 198–199why, one step back198test('stdin can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 0);199test('stdio[*] can be [Readable, "pipe"] without a file descriptor', testLazyFileReadable, 3);Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
line 200why, one step back200Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 201why, one step back201const testLazyFileWritable = async (t, fdNumber) => {Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 202–204why, one step back202 const filePath = tempfile();203 const stream = createWriteStream(filePath);204Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 205why, one step back205 await execa('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, [stream, 'pipe']));Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
line 206why, one step back206 t.is(await readFile(filePath, 'utf8'), 'foobar');Allow `stdin`/`stdout`/`stderr` to be an array (#643)ehmickybefore adoption7efd50c
lines 207–210why, one step back207208 await rm(filePath);209};210Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207
lines 211–213why, one step back211test('stdout can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 1);212test('stderr can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 2);213test('stdio[*] can be [Writable, "pipe"] without a file descriptor', testLazyFileWritable, 3);Wait for streams completion on errors (#722)ehmickybefore adoption195369f
line 214why, one step back214Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 215why, one step back215test('Waits for custom streams destroy on subprocess errors', async t => {Wait for streams completion on errors (#722)ehmickybefore adoption195369f
lines 216–218why, one step back216 let waitedForDestroy = false;217 const stream = new Writable({218 destroy: callbackify(async error => {Prefer `setImmediate()` over `setTimeout()` (#733)ehmickybefore adoption66d12bf
line 219why, one step back219 await setImmediate();Wait for streams completion on errors (#722)ehmickybefore adoption195369f
lines 220–223why, one step back220 waitedForDestroy = true;221 return error;222 }),223 });Improve process failure logic (#807)ehmickybefore adoption8ff263c
line 224why, one step back224 const {timedOut} = await t.throwsAsync(execa('forever.js', {stdout: [stream, 'pipe'], timeout: 1}));Wait for streams completion on errors (#722)ehmickybefore adoption195369f
lines 225–226why, one step back225 t.true(timedOut);226 t.true(waitedForDestroy);Improve process failure logic (#807)ehmickybefore adoption8ff263c
lines 227–228why, one step back227});228Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 229why, one step back229test('Handles custom streams destroy errors on subprocess success', async t => {Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 230why, one step back230 const cause = new Error('test');Improve process failure logic (#807)ehmickybefore adoption8ff263c
lines 231–232why, one step back231 const stream = new Writable({232 destroy(destroyError, done) {Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 233why, one step back233 done(destroyError ?? cause);Improve process failure logic (#807)ehmickybefore adoption8ff263c
lines 234–235why, one step back234 },235 });Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 236–237why, one step back236 const error = await t.throwsAsync(execa('empty.js', {stdout: [stream, 'pipe']}));237 t.is(error.cause, cause);Wait for streams completion on errors (#722)ehmickybefore adoption195369f
line 238why, one step back238});Destroy internal streams when process exits early (#770)ehmickybefore adoption8db0b09
lines 239–244why, one step back239240const testStreamEarlyExit = async (t, stream, streamName) => {241 await t.throwsAsync(execa('noop.js', {[streamName]: [stream, 'pipe'], uid: -1}));242 t.true(stream.destroyed);243};244Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 245–246why, one step back245test('Input streams are canceled on early subprocess exit', testStreamEarlyExit, noopReadable(), 'stdin');246test('Output streams are canceled on early subprocess exit', testStreamEarlyExit, noopWritable(), 'stdout');Improve stream cleanup and termination logic (#775)ehmickybefore adoption5aa90bd
line 247why, one step back247Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 248why, one step back248const testInputDuplexStream = async (t, fdNumber) => {Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
lines 249–250why, one step back249 const stream = new PassThrough();250 stream.end(foobarString);Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 251why, one step back251 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 252–257why, one step back252 t.is(stdout, foobarString);253};254255test('Can pass Duplex streams to stdin', testInputDuplexStream, 0);256test('Can pass Duplex streams to input stdio[*]', testInputDuplexStream, 3);257Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 258why, one step back258const testOutputDuplexStream = async (t, fdNumber) => {Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
lines 259–261why, one step back259 const stream = new PassThrough();260 const [output] = await Promise.all([261 text(stream),Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 262why, one step back262 execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe'])),Improve tests related to passing Node.js streams (#788)ehmickybefore adoption81f0b2d
lines 263–269why, one step back263 ]);264 t.is(output, foobarString);265};266267test('Can pass Duplex streams to stdout', testOutputDuplexStream, 1);268test('Can pass Duplex streams to stderr', testOutputDuplexStream, 2);269test('Can pass Duplex streams to output stdio[*]', testOutputDuplexStream, 3);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 270–274why, one step back270271const testInputStreamAbort = async (t, fdNumber) => {272 const stream = new PassThrough();273 stream.destroy();274Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 275–277why, one step back275 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));276 await subprocess;277 t.true(subprocess.stdio[fdNumber].writableEnded);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 278–279why, one step back278};279Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 280–281why, one step back280test('subprocess.stdin is ended when an input stream aborts', testInputStreamAbort, 0);281test('subprocess.stdio[*] is ended when an input stream aborts', testInputStreamAbort, 3);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 282–284why, one step back282283const testInputStreamError = async (t, fdNumber) => {284 const stream = new PassThrough();Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 285–286why, one step back285 const cause = new Error(foobarString);286 stream.destroy(cause);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
line 287why, one step back287Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 288why, one step back288 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 289why, one step back289 t.like(await t.throwsAsync(subprocess), {cause});Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 290why, one step back290 t.true(subprocess.stdio[fdNumber].writableEnded);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 291–292why, one step back291};292Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 293–294why, one step back293test('subprocess.stdin is ended when an input stream errors', testInputStreamError, 0);294test('subprocess.stdio[*] is ended when an input stream errors', testInputStreamError, 3);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 295–297why, one step back295296const testOutputStreamError = async (t, fdNumber) => {297 const stream = new PassThrough();Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
lines 298–299why, one step back298 const cause = new Error(foobarString);299 stream.destroy(cause);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
line 300why, one step back300Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 301why, one step back301 const subprocess = execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 302why, one step back302 t.like(await t.throwsAsync(subprocess), {cause});Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 303–304why, one step back303 t.true(subprocess.stdio[fdNumber].readableAborted);304 t.is(subprocess.stdio[fdNumber].errored, null);Improve streams pipe logic (#885)ehmickybefore adoption5abc429
lines 305–306why, one step back305};306Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 307–309why, one step back307test('subprocess.stdout is aborted when an output stream errors', testOutputStreamError, 1);308test('subprocess.stderr is aborted when an output stream errors', testOutputStreamError, 2);309test('subprocess.stdio[*] is aborted when an output stream errors', testOutputStreamError, 3);