readable.js
This file
Path
test/convert/readable.js
463 lines · 16.5 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 08eb743 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 2why, one step back2import {once} from 'node:events';TweaksSindre Sorhusbefore adoption698a1b8
lines 3–6why, one step back3import {pipeline} from 'node:stream/promises';4import {text} from 'node:stream/consumers';5import {setTimeout} from 'node:timers/promises';6import test from 'node:test';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 7–12why, one step back7import {8 compose,9 Readable,10 Writable,11 PassThrough,12} from 'node:stream';TweaksSindre Sorhusbefore adoption698a1b8
line 13why, one step back13import {assertRejects, assertLike} from '../helpers/assert.js';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 14–32why, one step back14import {execa} from '../../index.js';15import {setFixtureDirectory} from '../helpers/fixtures-directory.js';16import {17 finishedStream,18 assertReadableAborted,19 assertWritableAborted,20 assertProcessNormalExit,21 assertStreamOutput,22 assertStreamChunks,23 assertStreamError,24 assertStreamReadError,25 assertSubprocessOutput,26 assertSubprocessError,27 assertPromiseError,28 getReadableSubprocess,29 getReadWriteSubprocess,30} from '../helpers/convert.js';31import {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';32import {simpleFull} from '../helpers/lines.js';Runs CI tests on Node 23 (#1169)ehmickybefore adoptione330bd8
line 33why, one step back33import {majorNodeVersion} from '../helpers/node-version.js';Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 34–39why, one step back34import {prematureClose, fullStdio} from '../helpers/stdio.js';35import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';36import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';3738setFixtureDirectory();39TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40test('.readable() success', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 41–43why, one step back41 const subprocess = getReadableSubprocess();42 const stream = subprocess.readable();43TweaksSindre Sorhusbefore adoption698a1b8
lines 44–47why, one step back44 assert.ok(!(stream instanceof Writable));45 assert.equal(stream.writable, undefined);46 assert.ok(stream instanceof Readable);47 assert.equal(stream.readable, true);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 48why, one step back48TweaksSindre Sorhusbefore adoption698a1b8
lines 49–50why, one step back49 await assertStreamOutput(stream);50 await assertSubprocessOutput(subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 51–52why, one step back51});52TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53const testReadableDefault = async (fdNumber, from, options, hasResult) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 54–56why, one step back54 const subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], options);55 const stream = subprocess.readable({from});56TweaksSindre Sorhusbefore adoption698a1b8
lines 57–58why, one step back57 await assertStreamOutput(stream, hasResult ? foobarString : '');58 await assertSubprocessOutput(subprocess, foobarString, fdNumber);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 59–60why, one step back59};60TweaksSindre Sorhusbefore adoption698a1b8
lines 61–70why, one step back61test('.readable() can use stdout', () => testReadableDefault(1, 'stdout', {}, true));62test('.readable() can use stderr', () => testReadableDefault(2, 'stderr', {}, true));63test('.readable() can use stdio[*]', () => testReadableDefault(3, 'fd3', fullStdio, true));64test('.readable() uses stdout by default', () => testReadableDefault(1, undefined, {}, true));65test('.readable() does not use stderr by default', () => testReadableDefault(2, undefined, {}, false));66test('.readable() does not use stdio[*] by default', () => testReadableDefault(3, undefined, fullStdio, false));67test('.readable() uses stdout even if stderr is "ignore"', () => testReadableDefault(1, 'stdout', {stderr: 'ignore'}, true));68test('.readable() uses stderr even if stdout is "ignore"', () => testReadableDefault(2, 'stderr', {stdout: 'ignore'}, true));69test('.readable() uses stdout if "all" is used', () => testReadableDefault(1, 'all', {all: true}, true));70test('.readable() uses stderr if "all" is used', () => testReadableDefault(2, 'all', {all: true}, true));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 71why, one step back71TweaksSindre Sorhusbefore adoption698a1b8
line 72why, one step back72const testBuffering = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 73–79why, one step back73 const subprocess = execa('noop-stdin-fd.js', ['1'], {buffer: false});74 const stream = subprocess[methodName]();7576 subprocess.stdin.write(foobarString);77 await once(subprocess.stdout, 'readable');78 subprocess.stdin.end();79TweaksSindre Sorhusbefore adoption698a1b8
line 80why, one step back80 await assertStreamOutput(stream);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 81–82why, one step back81};82TweaksSindre Sorhusbefore adoption698a1b8
lines 83–84why, one step back83test('.readable() buffers until read', () => testBuffering('readable'));84test('.duplex() buffers until read', () => testBuffering('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 85why, one step back85TweaksSindre Sorhusbefore adoption698a1b8
line 86why, one step back86test('.readable() abort -> subprocess fail', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 87–91why, one step back87 const subprocess = execa('noop-repeat.js');88 const stream = subprocess.readable();8990 stream.destroy();91TweaksSindre Sorhusbefore adoption698a1b8
lines 92–98why, one step back92 const error = await assertRejects(text(stream));93 assertProcessNormalExit(error, 1);94 assert.ok(error.message.includes('EPIPE'));95 assertWritableAborted(subprocess.stdin);96 assertReadableAborted(subprocess.stdout);97 assert.equal(subprocess.stderr.readableEnded, true);98 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 99–100why, one step back99});100TweaksSindre Sorhusbefore adoption698a1b8
line 101why, one step back101test('.readable() error -> subprocess fail', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 102–107why, one step back102 const subprocess = execa('noop-repeat.js');103 const stream = subprocess.readable();104105 const cause = new Error(foobarString);106 stream.destroy(cause);107TweaksSindre Sorhusbefore adoption698a1b8
lines 108–114why, one step back108 const error = await assertStreamReadError(stream, {cause});109 assertProcessNormalExit(error, 1);110 assert.ok(error.message.includes('EPIPE'));111 assertWritableAborted(subprocess.stdin);112 assert.equal(subprocess.stdout.errored, cause);113 assert.equal(subprocess.stderr.readableEnded, true);114 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 115–116why, one step back115});116TweaksSindre Sorhusbefore adoption698a1b8
line 117why, one step back117const testStdoutAbort = async methodName => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 118why, one step back118 const subprocess = execa('ipc-echo.js', {ipc: true});Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 119–122why, one step back119 const stream = subprocess[methodName]();120121 subprocess.stdout.destroy();122Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 123why, one step back123 await subprocess.sendMessage(foobarString);Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 124why, one step back124 const [error, message] = await Promise.all([TweaksSindre Sorhusbefore adoption698a1b8
line 125why, one step back125 assertRejects(finishedStream(stream)),Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 126why, one step back126 subprocess.getOneMessage(),Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 127why, one step back127 ]);TweaksSindre Sorhusbefore adoption698a1b8
lines 128–133why, one step back128 assertLike(error, prematureClose);129 assert.equal(message, foobarString);130 assertWritableAborted(subprocess.stdin);131 assertReadableAborted(subprocess.stdout);132 assert.equal(subprocess.stderr.readableEnded, true);133 await assertSubprocessOutput(subprocess, '');Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 134–135why, one step back134};135TweaksSindre Sorhusbefore adoption698a1b8
lines 136–137why, one step back136test('subprocess.stdout abort + no more writes -> .readable() error + subprocess success', () => testStdoutAbort('readable'));137test('subprocess.stdout abort + no more writes -> .duplex() error + subprocess success', () => testStdoutAbort('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 138why, one step back138TweaksSindre Sorhusbefore adoption698a1b8
line 139why, one step back139const testStdoutError = async methodName => {Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 140why, one step back140 const subprocess = execa('ipc-echo.js', {ipc: true});Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 141–145why, one step back141 const stream = subprocess[methodName]();142143 const cause = new Error(foobarString);144 subprocess.stdout.destroy(cause);145Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 146why, one step back146 await subprocess.sendMessage(foobarString);Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
line 147why, one step back147 const [error, message] = await Promise.all([TweaksSindre Sorhusbefore adoption698a1b8
line 148why, one step back148 assertRejects(finishedStream(stream)),Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 149why, one step back149 subprocess.getOneMessage(),Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 150why, one step back150 ]);TweaksSindre Sorhusbefore adoption698a1b8
lines 151–156why, one step back151 assert.equal(message, foobarString);152 assert.equal(error.cause, cause);153 assertProcessNormalExit(error);154 assert.equal(subprocess.stdout.errored, cause);155 assert.equal(subprocess.stderr.readableEnded, true);156 assertWritableAborted(subprocess.stdin);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 157why, one step back157TweaksSindre Sorhusbefore adoption698a1b8
line 158why, one step back158 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 159–160why, one step back159};160TweaksSindre Sorhusbefore adoption698a1b8
lines 161–162why, one step back161test('subprocess.stdout error + no more writes -> .readable() error + subprocess fail', () => testStdoutError('readable'));162test('subprocess.stdout error + no more writes -> .duplex() error + subprocess fail', () => testStdoutError('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 163why, one step back163TweaksSindre Sorhusbefore adoption698a1b8
line 164why, one step back164const testStdinAbortWrites = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 165–170why, one step back165 const subprocess = getReadWriteSubprocess();166 const stream = subprocess[methodName]();167168 subprocess.stdout.destroy();169 subprocess.stdin.end(foobarString);170TweaksSindre Sorhusbefore adoption698a1b8
lines 171–176why, one step back171 const error = await assertRejects(finishedStream(stream));172 assertProcessNormalExit(error, 1);173 assert.equal(subprocess.stdin.writableEnded, true);174 assertReadableAborted(subprocess.stdout);175 assert.equal(subprocess.stderr.readableEnded, true);176 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 177–178why, one step back177};178TweaksSindre Sorhusbefore adoption698a1b8
lines 179–180why, one step back179test('subprocess.stdout abort + more writes -> .readable() error + subprocess fail', () => testStdinAbortWrites('readable'));180test('subprocess.stdout abort + more writes -> .duplex() error + subprocess fail', () => testStdinAbortWrites('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 181why, one step back181TweaksSindre Sorhusbefore adoption698a1b8
line 182why, one step back182const testStdinErrorWrites = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 183–189why, one step back183 const subprocess = getReadWriteSubprocess();184 const stream = subprocess[methodName]();185186 const cause = new Error(foobarString);187 subprocess.stdout.destroy(cause);188 subprocess.stdin.end(foobarString);189TweaksSindre Sorhusbefore adoption698a1b8
lines 190–195why, one step back190 const error = await assertStreamError(stream, {cause});191 assertProcessNormalExit(error, 1);192 assert.equal(subprocess.stdin.writableEnded, true);193 assert.equal(subprocess.stdout.errored, cause);194 assert.equal(subprocess.stderr.readableEnded, true);195 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 196–197why, one step back196};197TweaksSindre Sorhusbefore adoption698a1b8
lines 198–199why, one step back198test('subprocess.stdout error + more writes -> .readable() error + subprocess fail', () => testStdinErrorWrites('readable'));199test('subprocess.stdout error + more writes -> .duplex() error + subprocess fail', () => testStdinErrorWrites('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 200why, one step back200TweaksSindre Sorhusbefore adoption698a1b8
line 201why, one step back201test('.readable() can be used with Stream.pipeline()', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 202–208why, one step back202 const subprocess = getReadableSubprocess();203 const stream = subprocess.readable();204 const outputStream = new PassThrough();205206 await pipeline(stream, outputStream);207208 await finishedStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
lines 209–210why, one step back209 await assertStreamOutput(outputStream);210 await assertSubprocessOutput(subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 211–212why, one step back211});212TweaksSindre Sorhusbefore adoption698a1b8
line 213why, one step back213test('.readable() can error with Stream.pipeline()', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 214–217why, one step back214 const subprocess = execa('noop-fail.js', ['1', foobarString]);215 const stream = subprocess.readable();216 const outputStream = new PassThrough();217TweaksSindre Sorhusbefore adoption698a1b8
lines 218–220why, one step back218 const error = await assertRejects(pipeline(stream, outputStream));219 assertProcessNormalExit(error, 2);220 assertLike(error, {stdout: foobarString});Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 221why, one step back221TweaksSindre Sorhusbefore adoption698a1b8
lines 222–224why, one step back222 await assertStreamError(stream, error);223 await assertStreamReadError(outputStream, error);224 await assertSubprocessError(subprocess, error);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 225–226why, one step back225});226TweaksSindre Sorhusbefore adoption698a1b8
line 227why, one step back227test('.readable() can pipe to errored stream with Stream.pipeline()', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 228–234why, one step back228 const subprocess = getReadableSubprocess();229 const stream = subprocess.readable();230 const outputStream = new PassThrough();231232 const cause = new Error('test');233 outputStream.destroy(cause);234Runs CI tests on Node 23 (#1169)ehmickybefore adoptione330bd8
lines 235–237why, one step back235 // Node 23 does not allow calling `stream.pipeline()` with an already errored stream236 if (majorNodeVersion >= 23) {237 outputStream.on('error', () => {});TweaksSindre Sorhusbefore adoption698a1b8
line 238why, one step back238 await assertRejects(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});Runs CI tests on Node 23 (#1169)ehmickybefore adoptione330bd8
line 239why, one step back239 } else {TweaksSindre Sorhusbefore adoption698a1b8
lines 240–241why, one step back240 await assertPromiseError(pipeline(stream, outputStream), cause);241 await assertRejects(finishedStream(stream));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 242why, one step back242TweaksSindre Sorhusbefore adoption698a1b8
lines 243–245why, one step back243 const error = await assertStreamError(stream, cause);244 await assertStreamReadError(outputStream, cause);245 await assertSubprocessError(subprocess, {cause: error});Runs CI tests on Node 23 (#1169)ehmickybefore adoptione330bd8
line 246why, one step back246 }Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 247–248why, one step back247});248TweaksSindre Sorhusbefore adoption698a1b8
line 249why, one step back249test('.readable() can be used with Stream.compose()', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 250–253why, one step back250 const subprocess = getReadableSubprocess();251 const stream = subprocess.readable();252 const outputStream = new PassThrough();253TweaksSindre Sorhusbefore adoption698a1b8
lines 254–255why, one step back254 await assertStreamOutput(compose(stream, outputStream));255 await assertSubprocessOutput(subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 256–257why, one step back256});257TweaksSindre Sorhusbefore adoption698a1b8
line 258why, one step back258test('.readable() works with objectMode', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 259–260why, one step back259 const subprocess = execa('noop.js', {stdout: outputObjectGenerator()});260 const stream = subprocess.readable();TweaksSindre Sorhusbefore adoption698a1b8
lines 261–262why, one step back261 assert.equal(stream.readableObjectMode, true);262 assert.equal(stream.readableHighWaterMark, defaultObjectHighWaterMark);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 263why, one step back263TweaksSindre Sorhusbefore adoption698a1b8
lines 264–265why, one step back264 await assertStreamChunks(stream, [foobarObject]);265 await assertSubprocessOutput(subprocess, [foobarObject]);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 266–267why, one step back266});267TweaksSindre Sorhusbefore adoption698a1b8
line 268why, one step back268test('.duplex() works with objectMode and reads', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 269–270why, one step back269 const subprocess = getReadWriteSubprocess({stdout: outputObjectGenerator()});270 const stream = subprocess.duplex();TweaksSindre Sorhusbefore adoption698a1b8
lines 271–274why, one step back271 assert.equal(stream.readableObjectMode, true);272 assert.equal(stream.readableHighWaterMark, defaultObjectHighWaterMark);273 assert.equal(stream.writableObjectMode, false);274 assert.equal(stream.writableHighWaterMark, defaultHighWaterMark);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 275–276why, one step back275 stream.end(foobarString);276TweaksSindre Sorhusbefore adoption698a1b8
lines 277–278why, one step back277 await assertStreamChunks(stream, [foobarObject]);278 await assertSubprocessOutput(subprocess, [foobarObject]);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 279–280why, one step back279});280TweaksSindre Sorhusbefore adoption698a1b8
line 281why, one step back281test('.readable() works with default encoding', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 282–283why, one step back282 const subprocess = getReadableSubprocess();283 const stream = subprocess.readable();TweaksSindre Sorhusbefore adoption698a1b8
line 284why, one step back284 assert.equal(stream.readableEncoding, null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 285why, one step back285TweaksSindre Sorhusbefore adoption698a1b8
lines 286–287why, one step back286 await assertStreamChunks(stream, [foobarBuffer]);287 await assertSubprocessOutput(subprocess, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 288–289why, one step back288});289TweaksSindre Sorhusbefore adoption698a1b8
line 290why, one step back290test('.duplex() works with default encoding', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 291–292why, one step back291 const subprocess = getReadWriteSubprocess();292 const stream = subprocess.duplex();TweaksSindre Sorhusbefore adoption698a1b8
line 293why, one step back293 assert.equal(stream.readableEncoding, null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 294–295why, one step back294 stream.end(foobarString);295TweaksSindre Sorhusbefore adoption698a1b8
lines 296–297why, one step back296 await assertStreamChunks(stream, [foobarBuffer]);297 await assertSubprocessOutput(subprocess, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 298–299why, one step back298});299TweaksSindre Sorhusbefore adoption698a1b8
line 300why, one step back300test('.readable() works with encoding "utf8"', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 301–303why, one step back301 const subprocess = getReadableSubprocess();302 subprocess.stdout.setEncoding('utf8');303 const stream = subprocess.readable();TweaksSindre Sorhusbefore adoption698a1b8
line 304why, one step back304 assert.equal(stream.readableEncoding, 'utf8');Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 305why, one step back305TweaksSindre Sorhusbefore adoption698a1b8
lines 306–307why, one step back306 await assertStreamChunks(stream, [foobarString]);307 await assertSubprocessOutput(subprocess, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 308–309why, one step back308});309TweaksSindre Sorhusbefore adoption698a1b8
line 310why, one step back310test('.duplex() works with encoding "utf8"', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 311–313why, one step back311 const subprocess = getReadWriteSubprocess();312 subprocess.stdout.setEncoding('utf8');313 const stream = subprocess.duplex();TweaksSindre Sorhusbefore adoption698a1b8
line 314why, one step back314 assert.equal(stream.readableEncoding, 'utf8');Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 315–316why, one step back315 stream.end(foobarBuffer);316TweaksSindre Sorhusbefore adoption698a1b8
lines 317–318why, one step back317 await assertStreamChunks(stream, [foobarString]);318 await assertSubprocessOutput(subprocess, foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 319–320why, one step back319});320TweaksSindre Sorhusbefore adoption698a1b8
line 321why, one step back321test('.readable() has the right highWaterMark', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 322–323why, one step back322 const subprocess = execa('noop.js');323 const stream = subprocess.readable();TweaksSindre Sorhusbefore adoption698a1b8
line 324why, one step back324 assert.equal(stream.readableHighWaterMark, defaultHighWaterMark);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 325–327why, one step back325 await text(stream);326});327TweaksSindre Sorhusbefore adoption698a1b8
line 328why, one step back328test('.readable() can iterate over lines', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 329why, one step back329 const subprocess = execa('noop-fd.js', ['1', simpleFull]);Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 330why, one step back330 const lines = await Array.fromAsync(subprocess.readable({binary: false, preserveNewlines: false}));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 331–332why, one step back331332 const expectedLines = ['aaa', 'bbb', 'ccc'];TweaksSindre Sorhusbefore adoption698a1b8
lines 333–334why, one step back333 assert.deepEqual(lines, expectedLines);334 await assertSubprocessOutput(subprocess, simpleFull);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 335–336why, one step back335});336TweaksSindre Sorhusbefore adoption698a1b8
line 337why, one step back337test('.readable() can wait for data', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 338–340why, one step back338 const subprocess = execa('noop.js', {stdout: getOutputsAsyncGenerator([foobarString, foobarString])(false, true)});339 const stream = subprocess.readable();340TweaksSindre Sorhusbefore adoption698a1b8
line 341why, one step back341 assert.equal(stream.read(), null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 342why, one step back342 await once(stream, 'readable');TweaksSindre Sorhusbefore adoption698a1b8
lines 343–344why, one step back343 assert.equal(stream.read().toString(), foobarString);344 assert.equal(stream.read(), null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 345why, one step back345 await once(stream, 'readable');TweaksSindre Sorhusbefore adoption698a1b8
lines 346–347why, one step back346 assert.equal(stream.read().toString(), foobarString);347 assert.equal(stream.read(), null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 348why, one step back348 await once(stream, 'readable');TweaksSindre Sorhusbefore adoption698a1b8
line 349why, one step back349 assert.equal(stream.read(), null);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 350–351why, one step back350351 await finishedStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
line 352why, one step back352 await assertSubprocessOutput(subprocess, `${foobarString}${foobarString}`);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 353–354why, one step back353});354TweaksSindre Sorhusbefore adoption698a1b8
line 355why, one step back355const testBufferData = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 356–360why, one step back356 const chunk = '.'.repeat(defaultHighWaterMark).repeat(2);357 const subprocess = getReadWriteSubprocess();358 const stream = subprocess[methodName]();359 subprocess.stdin.end(chunk);360TweaksSindre Sorhusbefore adoption698a1b8
lines 361–362why, one step back361 await assertStreamOutput(stream, chunk);362 await assertSubprocessOutput(subprocess, chunk);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 363–364why, one step back363};364TweaksSindre Sorhusbefore adoption698a1b8
lines 365–366why, one step back365test('.readable() can buffer data', () => testBufferData('readable'));366test('.duplex() can buffer data', () => testBufferData('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 367why, one step back367TweaksSindre Sorhusbefore adoption698a1b8
line 368why, one step back368const assertDataEvents = async (stream, subprocess) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 369why, one step back369 const [output] = await once(stream, 'data');TweaksSindre Sorhusbefore adoption698a1b8
line 370why, one step back370 assert.equal(output.toString(), foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 371–372why, one step back371372 await finishedStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
line 373why, one step back373 await assertSubprocessOutput(subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 374–375why, one step back374};375TweaksSindre Sorhusbefore adoption698a1b8
line 376why, one step back376test('.readable() can be read with "data" events', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 377–379why, one step back377 const subprocess = getReadableSubprocess();378 const stream = subprocess.readable();379TweaksSindre Sorhusbefore adoption698a1b8
line 380why, one step back380 await assertDataEvents(stream, subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 381–382why, one step back381});382TweaksSindre Sorhusbefore adoption698a1b8
line 383why, one step back383test('.duplex() can be read with "data" events', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 384–387why, one step back384 const subprocess = getReadWriteSubprocess();385 const stream = subprocess.duplex();386 stream.end(foobarString);387TweaksSindre Sorhusbefore adoption698a1b8
line 388why, one step back388 await assertDataEvents(stream, subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 389–390why, one step back389});390TweaksSindre Sorhusbefore adoption698a1b8
line 391why, one step back391const assertPause = async (stream, subprocess) => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 392–394why, one step back392 const onceData = once(stream, 'data');393 stream.pause();394TweaksSindre Sorhusbefore adoption698a1b8
line 395why, one step back395 assert.equal(stream.readableLength, 0);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 396–400why, one step back396 do {397 // eslint-disable-next-line no-await-in-loop398 await setTimeout(10);399 } while (stream.readableLength === 0);400TweaksSindre Sorhusbefore adoption698a1b8
line 401why, one step back401 assert.ok(!await Promise.race([onceData, false]));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 402–404why, one step back402403 stream.resume();404 const [output] = await onceData;TweaksSindre Sorhusbefore adoption698a1b8
line 405why, one step back405 assert.equal(output.toString(), foobarString);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 406–407why, one step back406407 await finishedStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
line 408why, one step back408 await assertSubprocessOutput(subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 409–410why, one step back409};410TweaksSindre Sorhusbefore adoption698a1b8
line 411why, one step back411test('.readable() can be paused', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 412–414why, one step back412 const subprocess = getReadableSubprocess();413 const stream = subprocess.readable();414TweaksSindre Sorhusbefore adoption698a1b8
line 415why, one step back415 await assertPause(stream, subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 416–417why, one step back416});417TweaksSindre Sorhusbefore adoption698a1b8
line 418why, one step back418test('.duplex() can be paused', async () => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 419–422why, one step back419 const subprocess = getReadWriteSubprocess();420 const stream = subprocess.duplex();421 stream.end(foobarString);422TweaksSindre Sorhusbefore adoption698a1b8
line 423why, one step back423 await assertPause(stream, subprocess);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 424–427why, one step back424});425426// This feature does not work on Node 18.427// @todo: remove after dropping support for Node 18.Runs CI tests on Node 23 (#1169)ehmickybefore adoptione330bd8
line 428why, one step back428if (majorNodeVersion >= 20) {TweaksSindre Sorhusbefore adoption698a1b8
line 429why, one step back429 const testHighWaterMark = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 430–442why, one step back430 const subprocess = execa('stdin.js');431 const stream = subprocess[methodName]();432433 let count = 0;434 const onPause = once(subprocess.stdout, 'pause');435 for (; !subprocess.stdout.isPaused(); count += 1) {436 subprocess.stdin.write('.');437 // eslint-disable-next-line no-await-in-loop438 await Promise.race([onPause, once(subprocess.stdout, 'data')]);439 }440441 const expectedCount = defaultObjectHighWaterMark + 1;442 const expectedOutput = '.'.repeat(expectedCount);TweaksSindre Sorhusbefore adoption698a1b8
line 443why, one step back443 assert.equal(count, expectedCount);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
line 444why, one step back444 subprocess.stdin.end();TweaksSindre Sorhusbefore adoption698a1b8
lines 445–446why, one step back445 await assertStreamOutput(stream, expectedOutput);446 await assertSubprocessOutput(subprocess, expectedOutput);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 447–448why, one step back447 };448TweaksSindre Sorhusbefore adoption698a1b8
lines 449–450why, one step back449 test('.readable() pauses its buffering when too high', () => testHighWaterMark('readable'));450 test('.duplex() pauses its buffering when too high', () => testHighWaterMark('duplex'));Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 451–452why, one step back451}452TweaksSindre Sorhusbefore adoption698a1b8
line 453why, one step back453const testBigOutput = async methodName => {Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 454–457why, one step back454 const bigChunk = '.'.repeat(1e6);455 const subprocess = execa('stdin.js', {input: bigChunk});456 const stream = subprocess[methodName]();457TweaksSindre Sorhusbefore adoption698a1b8
lines 458–459why, one step back458 await assertStreamOutput(stream, bigChunk);459 await assertSubprocessOutput(subprocess, bigChunk);Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743
lines 460–461why, one step back460};461TweaksSindre Sorhusbefore adoption698a1b8
lines 462–463why, one step back462test('.readable() with big output', () => testBigOutput('readable'));463test('.duplex() with big output', () => testBigOutput('duplex'));