methods.js
This file
Path
test/pipe/methods.js
434 lines · 15.0 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 2–4why, one step back2import {setTimeout} from 'node:timers/promises';3import {Readable} from 'node:stream';4import {text} from 'node:stream/consumers';TweaksSindre Sorhusbefore adoption698a1b8
lines 5–6why, one step back5import test from 'node:test';6import {assertThrows, assertRejects} from '../helpers/assert.js';Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 7–10why, one step back7import {execa} from '../../index.js';8import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9import {simpleFull, noNewlinesFull, noNewlinesChunks} from '../helpers/lines.js';10import {foobarString, foobarArray} from '../helpers/input.js';TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11/* eslint-disable node-test/no-conditional-assertion -- shared helper functions are called from conditional paths on purpose */Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 12–21why, one step back1213setFixtureDirectory();1415const timeoutSymbol = Symbol('timeout');1617// `stdin.js` pipes its stdin to its stdout, so the piped output equals the source output18const pipeSimple = () => execa('noop-fd.js', ['1', simpleFull]).pipe('stdin.js');19const pipeAll = () => execa('noop-fd.js', ['1', simpleFull]).pipe('stdin.js', {all: true});20const pipeDistinctBoth = () => execa('noop-fd.js', ['1', simpleFull]).pipe('stdin-distinct-both.js');21TweaksSindre Sorhusbefore adoption698a1b8
line 22why, one step back22const assertSettles = async (promise, timeout = 1000) => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 23–28why, one step back23 const result = await Promise.race([24 promise,25 // Several pipe cancellation tests are specifically checking that a pending reader does not hang.26 setTimeout(timeout, timeoutSymbol, {ref: false}),27 ]);28TweaksSindre Sorhusbefore adoption698a1b8
line 29why, one step back29 assert.notEqual(result, timeoutSymbol);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 30–41why, one step back30 return result;31};3233const cleanupSubprocesses = async (...subprocesses) => {34 for (const subprocess of subprocesses) {35 subprocess.kill();36 }3738 await Promise.allSettled(subprocesses);39};4041const getPipeMessages = async piped => {Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 42why, one step back42 const messages = await Array.fromAsync(piped.getEachMessage());Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 43–46why, one step back4344 return messages;45};46TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47test('The .pipe() return value can be iterated', async () => {Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 48why, one step back48 const lines = await Array.fromAsync(pipeSimple());Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 49why, one step back49TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50 assert.deepEqual(lines, noNewlinesChunks);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 51–52why, one step back51});52TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53test('The .pipe() return value has an .iterable() method', async () => {Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 54why, one step back54 const lines = await Array.fromAsync(pipeSimple().iterable());Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 55why, one step back55TweaksSindre Sorhusbefore adoption698a1b8
line 56why, one step back56 assert.deepEqual(lines, noNewlinesChunks);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 57–58why, one step back57});58TweaksSindre Sorhusbefore adoption698a1b8
lines 59–60why, one step back59test('The .pipe() return value has a .readable() method', async () => {60 assert.equal(await text(pipeSimple().readable()), simpleFull);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 61–62why, one step back61});62TweaksSindre Sorhusbefore adoption698a1b8
lines 63–64why, one step back63test('The .pipe() return value has a .readableStream() method', async () => {64 assert.equal(await text(pipeSimple().readableStream()), simpleFull);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 65–66why, one step back65});66TweaksSindre Sorhusbefore adoption698a1b8
line 67why, one step back67test('The .pipe() return value .readable() can be called multiple times', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 68–73why, one step back68 const piped = pipeSimple();69 const [output, secondOutput] = await Promise.all([70 text(piped.readable()),71 text(piped.readable()),72 ]);73TweaksSindre Sorhusbefore adoption698a1b8
lines 74–75why, one step back74 assert.equal(output, simpleFull);75 assert.equal(secondOutput, simpleFull);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 76–77why, one step back76});77TweaksSindre Sorhusbefore adoption698a1b8
line 78why, one step back78test('The .pipe() return value .readable() keeps conversion options', async () => {Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 79why, one step back79 const chunks = await Array.fromAsync(pipeSimple().readable({binary: false, preserveNewlines: false}));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 80why, one step back80TweaksSindre Sorhusbefore adoption698a1b8
lines 81–82why, one step back81 assert.deepEqual(chunks, noNewlinesChunks);82 assert.equal(chunks.join(''), noNewlinesFull);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 83–84why, one step back83});84TweaksSindre Sorhusbefore adoption698a1b8
line 85why, one step back85test('The .pipe() return value does not have a .writable() method', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 86why, one step back86 const piped = pipeSimple();TweaksSindre Sorhusbefore adoption698a1b8
lines 87–90why, one step back87 assert.equal(piped.writable, undefined);88 assert.equal(piped.duplex, undefined);89 assert.equal(piped.writableStream, undefined);90 assert.equal(piped.transformStream, undefined);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 91–93why, one step back91 await piped;92});93TweaksSindre Sorhusbefore adoption698a1b8
line 94why, one step back94test('The .pipe() return value does not have .all unless destination uses the "all" option', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 95–97why, one step back95 const piped = pipeSimple();96 const descriptor = Object.getOwnPropertyDescriptor(piped, 'all');97TweaksSindre Sorhusbefore adoption698a1b8
lines 98–100why, one step back98 assert.equal(piped.all, undefined);99 assert.equal(descriptor.value, undefined);100 assert.equal(descriptor.get, undefined);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 101–103why, one step back101 await piped;102});103TweaksSindre Sorhusbefore adoption698a1b8
line 104why, one step back104test('The .pipe() return value has an .all property', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 105why, one step back105 const piped = pipeAll();TweaksSindre Sorhusbefore adoption698a1b8
lines 106–107why, one step back106 assert.ok(piped.all instanceof Readable);107 assert.equal(await text(piped.all), simpleFull);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 108–110why, one step back108 await piped;109});110TweaksSindre Sorhusbefore adoption698a1b8
line 111why, one step back111test('The .pipe() return value .all is created lazily and cached', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 112–114why, one step back112 const piped = pipeAll();113 const descriptor = Object.getOwnPropertyDescriptor(piped, 'all');114TweaksSindre Sorhusbefore adoption698a1b8
line 115why, one step back115 assert.equal(typeof descriptor.get, 'function');Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 116why, one step back116 const {all} = piped;TweaksSindre Sorhusbefore adoption698a1b8
lines 117–120why, one step back117 assert.ok(all instanceof Readable);118 assert.equal(piped.all, all);119 assert.equal(Object.getOwnPropertyDescriptor(piped, 'all').get, undefined);120 assert.equal(await text(all), simpleFull);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 121–123why, one step back121 await piped;122});123TweaksSindre Sorhusbefore adoption698a1b8
line 124why, one step back124test('The .pipe() return value .readable() can read destination stderr', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 125–126why, one step back125 const piped = pipeDistinctBoth();126TweaksSindre Sorhusbefore adoption698a1b8
line 127why, one step back127 assert.equal(await text(piped.readable({from: 'stderr'})), `${simpleFull}:stderr`);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 128–130why, one step back128 await piped;129});130TweaksSindre Sorhusbefore adoption698a1b8
line 131why, one step back131test('The .pipe() return value .iterable() can read destination stderr', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 132why, one step back132 const piped = pipeDistinctBoth();Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 133why, one step back133 const lines = await Array.fromAsync(piped.iterable({from: 'stderr'}));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 134why, one step back134TweaksSindre Sorhusbefore adoption698a1b8
line 135why, one step back135 assert.deepEqual(lines, ['aaa', 'bbb', 'ccc:stderr']);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 136–138why, one step back136 await piped;137});138TweaksSindre Sorhusbefore adoption698a1b8
line 139why, one step back139test('The .pipe() return value has IPC methods', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 140why, one step back140 const piped = execa('empty.js').pipe('ipc-send-twice.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 141why, one step back141 assert.deepEqual(await getPipeMessages(piped), foobarArray);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 142why, one step back142 const {ipcOutput} = await piped;TweaksSindre Sorhusbefore adoption698a1b8
line 143why, one step back143 assert.deepEqual(ipcOutput, foobarArray);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 144–145why, one step back144});145TweaksSindre Sorhusbefore adoption698a1b8
line 146why, one step back146test('The .pipe() return value .getEachMessage() can be called twice at the same time', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 147–148why, one step back147 const piped = execa('empty.js').pipe('ipc-send-twice.js', {ipc: true});148TweaksSindre Sorhusbefore adoption698a1b8
line 149why, one step back149 assert.deepEqual(Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 150–154why, one step back150 await Promise.all([getPipeMessages(piped), getPipeMessages(piped)]),151 [foobarArray, foobarArray],152 );153154 const {ipcOutput} = await piped;TweaksSindre Sorhusbefore adoption698a1b8
line 155why, one step back155 assert.deepEqual(ipcOutput, foobarArray);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 156–157why, one step back156});157TweaksSindre Sorhusbefore adoption698a1b8
line 158why, one step back158test('The .pipe() return value .getEachMessage() preserves setup errors', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 159–160why, one step back159 const piped = execa('empty.js').pipe('ipc-send-twice.js', {ipc: true});160TweaksSindre Sorhusbefore adoption698a1b8
line 161why, one step back161 assertThrows(() => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 162–167why, one step back162 piped.getEachMessage(null);163 }, {instanceOf: TypeError});164165 await piped;166});167TweaksSindre Sorhusbefore adoption698a1b8
line 168why, one step back168test('The .pipe() return value .getEachMessage() waits for source failure', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 169–170why, one step back169 const piped = execa('fail.js').pipe('ipc-send-twice.js', {ipc: true});170TweaksSindre Sorhusbefore adoption698a1b8
line 171why, one step back171 await assertRejects(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 172why, one step back172 for await (const message of piped.getEachMessage()) {TweaksSindre Sorhusbefore adoption698a1b8
line 173why, one step back173 assert.ok(foobarArray.includes(message));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 174–181why, one step back174 }175 }, {message: /Command failed with exit code 2/});176});177178test('The .pipe() return value .getEachMessage() waits for pipe cancellation', async t => {179 const abortController = new AbortController();180 const source = execa('noop-repeat.js');181 const destination = execa('ipc-send-forever.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 182why, one step back182 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 183–187why, one step back183 await cleanupSubprocesses(source, destination);184 });185186 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});187 const iterator = piped.getEachMessage();TweaksSindre Sorhusbefore adoption698a1b8
line 188why, one step back188 assert.deepEqual(await iterator.next(), {done: false, value: foobarString});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 189why, one step back189TweaksSindre Sorhusbefore adoption698a1b8
line 190why, one step back190 const readerPromise = assertRejects(iterator.next(), {message: /Pipe canceled/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 191why, one step back191 abortController.abort();TweaksSindre Sorhusbefore adoption698a1b8
line 192why, one step back192 await assertSettles(readerPromise);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 193–198why, one step back193});194195test('The .pipe() return value .getEachMessage() cancels every pending reader', async t => {196 const abortController = new AbortController();197 const source = execa('noop-repeat.js');198 const destination = execa('ipc-send-forever.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 199why, one step back199 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 200–208why, one step back200 await cleanupSubprocesses(source, destination);201 });202203 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});204 const iterators = [205 piped.getEachMessage(),206 piped.getEachMessage(),207 ];208TweaksSindre Sorhusbefore adoption698a1b8
line 209why, one step back209 assert.deepEqual(Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 210–216why, one step back210 await Promise.all(iterators.map(async iterator => iterator.next())),211 [212 {done: false, value: foobarString},213 {done: false, value: foobarString},214 ],215 );216TweaksSindre Sorhusbefore adoption698a1b8
line 217why, one step back217 const readerPromises = iterators.map(iterator => assertRejects(iterator.next(), {message: /Pipe canceled/}));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 218why, one step back218 abortController.abort();TweaksSindre Sorhusbefore adoption698a1b8
line 219why, one step back219 await Promise.all(readerPromises.map(async readerPromise => assertSettles(readerPromise)));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 220–221why, one step back220});221Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 222why, one step back222const assertCanceledPipeMessageReader = async (t, getReader, shouldAbortBeforePipe = false) => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 223why, one step back223 const abortController = new AbortController();Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 224why, one step back224 if (shouldAbortBeforePipe) {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 225–229why, one step back225 abortController.abort();226 }227228 const source = execa('noop-repeat.js');229 const destination = execa('ipc-get.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 230why, one step back230 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 231–234why, one step back231 await cleanupSubprocesses(source, destination);232 });233234 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});TweaksSindre Sorhusbefore adoption698a1b8
line 235why, one step back235 const readerPromise = assertRejects(getReader(piped), {message: /Pipe canceled/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 236why, one step back236Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 237why, one step back237 if (!shouldAbortBeforePipe) {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 238–240why, one step back238 abortController.abort();239 }240TweaksSindre Sorhusbefore adoption698a1b8
lines 241–242why, one step back241 await assertSettles(readerPromise);242 await assertRejects(piped, {message: /Pipe canceled/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 243–263why, one step back243};244245test('The .pipe() return value .getEachMessage() waits for pipe cancellation before IPC messages', async t => {246 await assertCanceledPipeMessageReader(t, piped => piped.getEachMessage().next());247});248249test('The .pipe() return value .getEachMessage() waits for already canceled pipes', async t => {250 await assertCanceledPipeMessageReader(t, piped => piped.getEachMessage().next(), true);251});252253test('The .pipe() return value .getOneMessage() waits for pipe cancellation before IPC messages', async t => {254 await assertCanceledPipeMessageReader(t, piped => piped.getOneMessage());255});256257test('The .pipe() return value .getOneMessage() waits for already canceled pipes', async t => {258 await assertCanceledPipeMessageReader(t, piped => piped.getOneMessage(), true);259});260261test('The .pipe() return value .getEachMessage() waits for the pipe when the iterator is returned', async t => {262 const source = execa('empty.js');263 const destination = execa('ipc-send-forever.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 264why, one step back264 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 265–270why, one step back265 await cleanupSubprocesses(source, destination);266 });267268 const piped = source.pipe(destination);269 const iterator = piped.getEachMessage();270TweaksSindre Sorhusbefore adoption698a1b8
lines 271–272why, one step back271 assert.deepEqual(await iterator.next(), {done: false, value: foobarString});272 const returnPromise = assertRejects(iterator.return());Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 273–274why, one step back273 destination.kill();274 const error = await returnPromise;TweaksSindre Sorhusbefore adoption698a1b8
line 275why, one step back275 assert.equal(error.isTerminated, true);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 276–278why, one step back276 await Promise.allSettled([source, destination, piped]);277});278TweaksSindre Sorhusbefore adoption698a1b8
line 279why, one step back279test('The .pipe() return value .getEachMessage() propagates source failure when the iterator is returned', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 280–283why, one step back280 const source = execa('ipc-echo-fail.js', {ipc: true});281 const piped = source.pipe('ipc-send-wait-print.js', {ipc: true});282 const iterator = piped.getEachMessage();283TweaksSindre Sorhusbefore adoption698a1b8
lines 284–285why, one step back284 assert.deepEqual(await iterator.next(), {done: false, value: foobarString});285 const returnPromise = assertRejects(iterator.return(), {message: /Command failed with exit code 1/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 286–289why, one step back286 await source.sendMessage(foobarString);287 await returnPromise;288});289TweaksSindre Sorhusbefore adoption698a1b8
line 290why, one step back290test('The .pipe() return value .getEachMessage() propagates destination failure', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 291–292why, one step back291 const piped = execa('empty.js').pipe('ipc-send-fail.js', {ipc: true});292TweaksSindre Sorhusbefore adoption698a1b8
line 293why, one step back293 await assertRejects(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 294why, one step back294 for await (const message of piped.getEachMessage()) {TweaksSindre Sorhusbefore adoption698a1b8
line 295why, one step back295 assert.equal(message, foobarString);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 296–298why, one step back296 }297 }, {message: /Command failed with exit code 1/});298TweaksSindre Sorhusbefore adoption698a1b8
lines 299–300why, one step back299 const {ipcOutput} = await assertRejects(piped);300 assert.deepEqual(ipcOutput, [foobarString]);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 301–302why, one step back301});302TweaksSindre Sorhusbefore adoption698a1b8
line 303why, one step back303test('The .pipe() return value .getEachMessage() waits for the pipe when the consumer throws', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 304–306why, one step back304 const piped = execa('empty.js').pipe('ipc-send-wait-print.js', {ipc: true});305 const cause = new Error(foobarString);306TweaksSindre Sorhusbefore adoption698a1b8
line 307why, one step back307 assert.equal(await assertRejects(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 308–309why, one step back308 // eslint-disable-next-line no-unreachable-loop309 for await (const message of piped.getEachMessage()) {TweaksSindre Sorhusbefore adoption698a1b8
line 310why, one step back310 assert.equal(message, foobarString);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 311–315why, one step back311 throw cause;312 }313 }), cause);314315 const {ipcOutput, stdout} = await piped;TweaksSindre Sorhusbefore adoption698a1b8
lines 316–317why, one step back316 assert.deepEqual(ipcOutput, [foobarString]);317 assert.equal(stdout, '.');Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 318–322why, one step back318});319320test('The .pipe() return value .getEachMessage() validates IPC immediately', async t => {321 const source = execa('stdin.js');322 const destination = execa('stdin.js');TweaksSindre Sorhusbefore adoption698a1b8
line 323why, one step back323 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 324–327why, one step back324 await cleanupSubprocesses(source, destination);325 });326327 const piped = source.pipe(destination);TweaksSindre Sorhusbefore adoption698a1b8
line 328why, one step back328 const {message} = assertThrows(() => piped.getEachMessage());Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 329why, one step back329TweaksSindre Sorhusbefore adoption698a1b8
line 330why, one step back330 assert.ok(message.includes('subprocess.getEachMessage() can only be used'));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 331–335why, one step back331 source.kill();332 destination.kill();333 await Promise.allSettled([source, destination, piped]);334});335TweaksSindre Sorhusbefore adoption698a1b8
line 336why, one step back336test('The .pipe() return value can exchange IPC messages', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 337–338why, one step back337 const piped = execa('empty.js').pipe('ipc-echo.js', {ipc: true});338 await piped.sendMessage(foobarString);TweaksSindre Sorhusbefore adoption698a1b8
line 339why, one step back339 assert.equal(await piped.getOneMessage(), foobarString);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 340–342why, one step back340 await piped;341});342TweaksSindre Sorhusbefore adoption698a1b8
line 343why, one step back343test('A chained .pipe() return value can be iterated', async () => {Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 344why, one step back344 const lines = await Array.fromAsync(execa('noop-fd.js', ['1', simpleFull]).pipe('stdin.js').pipe('stdin.js'));Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 345why, one step back345TweaksSindre Sorhusbefore adoption698a1b8
line 346why, one step back346 assert.deepEqual(lines, noNewlinesChunks);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 347–348why, one step back347});348TweaksSindre Sorhusbefore adoption698a1b8
lines 349–350why, one step back349test('The .pipe() return value still awaits both subprocesses', async () => {350 await assertRejects(execa('fail.js').pipe('stdin.js'), {message: /Command failed with exit code 2/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 351–352why, one step back351});352TweaksSindre Sorhusbefore adoption698a1b8
line 353why, one step back353test('The .pipe() return value iteration waits for source failure', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 354–355why, one step back354 const piped = execa('fail.js').pipe('stdin.js');355TweaksSindre Sorhusbefore adoption698a1b8
line 356why, one step back356 await assertRejects(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 357why, one step back357 for await (const line of piped) {TweaksSindre Sorhusbefore adoption698a1b8
line 358why, one step back358 assert.fail(`Unexpected line: ${line}`);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 359–362why, one step back359 }360 }, {message: /Command failed with exit code 2/});361});362TweaksSindre Sorhusbefore adoption698a1b8
line 363why, one step back363test('The .pipe() return value .readable() waits for source failure', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 364–365why, one step back364 const piped = execa('fail.js').pipe('stdin.js');365TweaksSindre Sorhusbefore adoption698a1b8
line 366why, one step back366 await assertRejects(text(piped.readable()), {message: /Command failed with exit code 2/});Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 367–368why, one step back367});368TweaksSindre Sorhusbefore adoption698a1b8
line 369why, one step back369test('The .pipe() return value .readableStream() waits for source failure', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 370–371why, one step back370 const piped = execa('fail.js').pipe('stdin.js');371TweaksSindre Sorhusbefore adoption698a1b8
line 372why, one step back372 await assertRejects(text(piped.readableStream()), {message: /Command failed with exit code 2/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 373–374why, one step back373});374TweaksSindre Sorhusbefore adoption698a1b8
line 375why, one step back375test('The .pipe() return value .all waits for source failure', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 376–377why, one step back376 const piped = execa('fail.js').pipe('stdin.js', {all: true});377TweaksSindre Sorhusbefore adoption698a1b8
line 378why, one step back378 await assertRejects(text(piped.all), {message: /Command failed with exit code 2/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 379–380why, one step back379});380Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 381why, one step back381const assertCanceledPipeReader = async (t, getReader, shouldAbortBeforePipe = false) => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 382why, one step back382 const abortController = new AbortController();Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 383why, one step back383 if (shouldAbortBeforePipe) {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 384–388why, one step back384 abortController.abort();385 }386387 const source = execa('stdin.js');388 const destination = execa('stdin.js', {all: true});TweaksSindre Sorhusbefore adoption698a1b8
line 389why, one step back389 t.after(async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 390–393why, one step back390 await cleanupSubprocesses(source, destination);391 });392393 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});TweaksSindre Sorhusbefore adoption698a1b8
line 394why, one step back394 const readerPromise = assertRejects(getReader(piped), {message: /Pipe canceled/});Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
line 395why, one step back395Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 396why, one step back396 if (!shouldAbortBeforePipe) {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 397–399why, one step back397 abortController.abort();398 }399TweaksSindre Sorhusbefore adoption698a1b8
line 400why, one step back400 await assertSettles(readerPromise, 200);Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 401–418why, one step back401};402403test('The .pipe() return value .readable() waits for pipe cancellation', async t => {404 await assertCanceledPipeReader(t, piped => text(piped.readable()));405});406407test('The .pipe() return value .all waits for pipe cancellation', async t => {408 await assertCanceledPipeReader(t, piped => text(piped.all));409});410411test('The .pipe() return value .readable() waits for already canceled pipes', async t => {412 await assertCanceledPipeReader(t, piped => text(piped.readable()), true);413});414415test('The .pipe() return value .all waits for already canceled pipes', async t => {416 await assertCanceledPipeReader(t, piped => text(piped.all), true);417});418TweaksSindre Sorhusbefore adoption698a1b8
line 419why, one step back419test('Multiple sources piped to one destination each expose the destination methods', async () => {Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 420–426why, one step back420 const destination = execa('stdin.js');421 const piped = [422 execa('noop-fd.js', ['1', foobarString]).pipe(destination),423 execa('noop-fd.js', ['1', foobarString]).pipe(destination),424 ];425426 for (const pipePromise of piped) {TweaksSindre Sorhusbefore adoption698a1b8
lines 427–428why, one step back427 assert.equal(typeof pipePromise.iterable, 'function');428 assert.equal(typeof pipePromise[Symbol.asyncIterator], 'function');Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c
lines 429–432why, one step back429 }430431 await Promise.all(piped);432});TweaksSindre Sorhusbefore adoption698a1b8
lines 433–434why, one step back433434/* eslint-enable node-test/no-conditional-assertion */