Skip to content
Myr

concurrent.js

This file

Path

test/convert/concurrent.js

372 lines · 12.7 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

line 1why, one step back
1import assert from 'node:assert/strict';

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 3why, one step back
3import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–24why, one step back
4import {execa} from '../../index.js';
5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString} from '../helpers/input.js';7import {fullReadableStdio} from '../helpers/stdio.js';8import {9 finishedStream,10 assertStreamOutput,11 assertStreamError,12 assertStreamReadError,13 assertSubprocessOutput,14 assertSubprocessError,15 getReadWriteSubprocess,16} from '../helpers/convert.js';1718setFixtureDirectory();1920const endStream = async stream => {21 stream.end(foobarString);22 await setTimeout(0);23};24

TweaksSindre Sorhusbefore adoption698a1b8

line 25why, one step back
25const endSameWritable = async (stream, secondStream, subprocess, fdNumber) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 26why, one step back
26 await endStream(stream);

TweaksSindre Sorhusbefore adoption698a1b8

line 27why, one step back
27 assert.ok(subprocess.stdio[fdNumber].writable);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 28–29why, one step back
28
29 await endStream(secondStream);

TweaksSindre Sorhusbefore adoption698a1b8

line 30why, one step back
30 assert.ok(!subprocess.stdio[fdNumber].writable);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 31–33why, one step back
31};
3233// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 34why, one step back
34const endDifferentWritable = async (stream, secondStream, subprocess, fdNumber = 0, secondFdNumber = 3) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 35why, one step back
35 await endStream(stream);

TweaksSindre Sorhusbefore adoption698a1b8

lines 36–37why, one step back
36 assert.ok(!subprocess.stdio[fdNumber].writable);
37 assert.ok(subprocess.stdio[secondFdNumber].writable);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 38–39why, one step back
38
39 await endStream(secondStream);

TweaksSindre Sorhusbefore adoption698a1b8

line 40why, one step back
40 assert.ok(!subprocess.stdio[secondFdNumber].writable);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 41–42why, one step back
41};
42

TweaksSindre Sorhusbefore adoption698a1b8

line 43why, one step back
43const testReadableTwice = async (fdNumber, from) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 44–48why, one step back
44 const subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString]);
45 const stream = subprocess.readable({from});46 const secondStream = subprocess.readable({from});4748 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 49–50why, one step back
49 assertStreamOutput(stream),
50 assertStreamOutput(secondStream),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 51why, one step back
51 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 52why, one step back
52 await assertSubprocessOutput(subprocess, foobarString, fdNumber);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 53–54why, one step back
53};
54

TweaksSindre Sorhusbefore adoption698a1b8

lines 55–56why, one step back
55test('Can call .readable() twice on same file descriptor', () => testReadableTwice(1));
56test('Can call .readable({from: "stderr"}) twice on same file descriptor', () => testReadableTwice(2, 'stderr'));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 57why, one step back
57

TweaksSindre Sorhusbefore adoption698a1b8

line 58why, one step back
58const testWritableTwice = async (fdNumber, to, options) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 59–65why, one step back
59 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);
60 const stream = subprocess.writable({to});61 const secondStream = subprocess.writable({to});6263 await Promise.all([64 finishedStream(stream),65 finishedStream(secondStream),

TweaksSindre Sorhusbefore adoption698a1b8

line 66why, one step back
66 endSameWritable(stream, secondStream, subprocess, fdNumber),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 67why, one step back
67 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 68why, one step back
68 await assertSubprocessOutput(subprocess, `${foobarString}${foobarString}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 69–70why, one step back
69};
70

TweaksSindre Sorhusbefore adoption698a1b8

lines 71–72why, one step back
71test('Can call .writable() twice on same file descriptor', () => testWritableTwice(0, undefined, {}));
72test('Can call .writable({to: "fd3"}) twice on same file descriptor', () => testWritableTwice(3, 'fd3', fullReadableStdio()));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 73why, one step back
73

TweaksSindre Sorhusbefore adoption698a1b8

line 74why, one step back
74const testDuplexTwice = async (fdNumber, to, options) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 75–80why, one step back
75 const subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);
76 const stream = subprocess.duplex({to});77 const secondStream = subprocess.duplex({to});7879 const expectedOutput = `${foobarString}${foobarString}`;80 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 81–83why, one step back
81 assertStreamOutput(stream, expectedOutput),
82 assertStreamOutput(secondStream, expectedOutput),83 endSameWritable(stream, secondStream, subprocess, fdNumber),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 84why, one step back
84 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 85why, one step back
85 await assertSubprocessOutput(subprocess, expectedOutput);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 88–89why, one step back
88test('Can call .duplex() twice on same file descriptor', () => testDuplexTwice(0, undefined, {}));
89test('Can call .duplex({to: "fd3"}) twice on same file descriptor', () => testDuplexTwice(3, 'fd3', fullReadableStdio()));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 90why, one step back
90

TweaksSindre Sorhusbefore adoption698a1b8

line 91why, one step back
91test('Can call .duplex() twice on same readable file descriptor but different writable one', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 92–97why, one step back
92 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());
93 const stream = subprocess.duplex();94 const secondStream = subprocess.duplex({to: 'fd3'});9596 const expectedOutput = `${foobarString}${foobarString}`;97 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 98–100why, one step back
98 assertStreamOutput(stream, expectedOutput),
99 assertStreamOutput(secondStream, expectedOutput),100 endDifferentWritable(stream, secondStream, subprocess),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 101why, one step back
101 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 102why, one step back
102 await assertSubprocessOutput(subprocess, expectedOutput);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 103–104why, one step back
103});
104

TweaksSindre Sorhusbefore adoption698a1b8

line 105why, one step back
105test('Can call .readable() twice on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 106–111why, one step back
106 const subprocess = execa('noop-both.js', [foobarString]);
107 const stream = subprocess.readable();108 const secondStream = subprocess.readable({from: 'stderr'});109110 const expectedOutput = `${foobarString}\n`;111 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 112–113why, one step back
112 assertStreamOutput(stream, expectedOutput),
113 assertStreamOutput(secondStream, expectedOutput),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 114why, one step back
114 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 115–116why, one step back
115 await assertSubprocessOutput(subprocess);
116 await assertSubprocessOutput(subprocess, foobarString, 2);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 117–118why, one step back
117});
118

TweaksSindre Sorhusbefore adoption698a1b8

line 119why, one step back
119test('Can call .writable() twice on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 120–126why, one step back
120 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());
121 const stream = subprocess.writable();122 const secondStream = subprocess.writable({to: 'fd3'});123124 await Promise.all([125 finishedStream(stream),126 finishedStream(secondStream),

TweaksSindre Sorhusbefore adoption698a1b8

line 127why, one step back
127 endDifferentWritable(stream, secondStream, subprocess),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 128why, one step back
128 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 129why, one step back
129 await assertSubprocessOutput(subprocess, `${foobarString}${foobarString}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 130–131why, one step back
130});
131

TweaksSindre Sorhusbefore adoption698a1b8

line 132why, one step back
132test('Can call .duplex() twice on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 133–137why, one step back
133 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());
134 const stream = subprocess.duplex();135 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});136137 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 138–140why, one step back
138 assertStreamOutput(stream),
139 assertStreamOutput(secondStream),140 endDifferentWritable(stream, secondStream, subprocess),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 141why, one step back
141 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 142–143why, one step back
142 await assertSubprocessOutput(subprocess);
143 await assertSubprocessOutput(subprocess, foobarString, 2);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 144–145why, one step back
144});
145

TweaksSindre Sorhusbefore adoption698a1b8

line 146why, one step back
146test('Can call .readable() and .writable()', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 147–153why, one step back
147 const subprocess = getReadWriteSubprocess();
148 const stream = subprocess.writable();149 const secondStream = subprocess.readable();150 stream.end(foobarString);151152 await Promise.all([153 finishedStream(stream),

TweaksSindre Sorhusbefore adoption698a1b8

line 154why, one step back
154 assertStreamOutput(secondStream),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 155why, one step back
155 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 156why, one step back
156 await assertSubprocessOutput(subprocess);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 159why, one step back
159test('Can call .writable() and .duplex()', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 160–165why, one step back
160 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());
161 const stream = subprocess.duplex();162 const secondStream = subprocess.writable({to: 'fd3'});163164 const expectedOutput = `${foobarString}${foobarString}`;165 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

line 166why, one step back
166 assertStreamOutput(stream, expectedOutput),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 167why, one step back
167 finishedStream(secondStream),

TweaksSindre Sorhusbefore adoption698a1b8

line 168why, one step back
168 endDifferentWritable(stream, secondStream, subprocess),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 169why, one step back
169 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 170why, one step back
170 await assertSubprocessOutput(subprocess, expectedOutput);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 171–172why, one step back
171});
172

TweaksSindre Sorhusbefore adoption698a1b8

line 173why, one step back
173test('Can call .readable() and .duplex()', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 174–179why, one step back
174 const subprocess = execa('stdin-both.js');
175 const stream = subprocess.duplex();176 const secondStream = subprocess.readable({from: 'stderr'});177 stream.end(foobarString);178179 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 180–181why, one step back
180 assertStreamOutput(stream),
181 assertStreamOutput(secondStream),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 182why, one step back
182 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 183–184why, one step back
183 await assertSubprocessOutput(subprocess);
184 await assertSubprocessOutput(subprocess, foobarString, 2);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 185–186why, one step back
185});
186

TweaksSindre Sorhusbefore adoption698a1b8

line 187why, one step back
187test('Can error one of two .readable() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 188–194why, one step back
188 const subprocess = execa('noop-fd.js', ['1', foobarString]);
189 const stream = subprocess.readable();190 const secondStream = subprocess.readable();191 const cause = new Error(foobarString);192 stream.destroy(cause);193194 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 195–196why, one step back
195 assertStreamReadError(stream, cause),
196 assertStreamOutput(secondStream),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 197why, one step back
197 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 198why, one step back
198 await assertSubprocessOutput(subprocess);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 199–200why, one step back
199});
200

TweaksSindre Sorhusbefore adoption698a1b8

line 201why, one step back
201test('Can error both .readable() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 202–209why, one step back
202 const subprocess = execa('noop-fd.js', ['1', foobarString]);
203 const stream = subprocess.readable();204 const secondStream = subprocess.readable();205 const cause = new Error(foobarString);206 stream.destroy(cause);207 secondStream.destroy(cause);208209 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 210–211why, one step back
210 assertStreamReadError(stream, {cause}),
211 assertStreamReadError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 212why, one step back
212 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 213–214why, one step back
213 assert.equal(error, secondError);
214 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 215–216why, one step back
215});
216

TweaksSindre Sorhusbefore adoption698a1b8

line 217why, one step back
217test('Can error one of two .readable() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 218–224why, one step back
218 const subprocess = execa('noop-both.js', [foobarString]);
219 const stream = subprocess.readable();220 const secondStream = subprocess.readable({from: 'stderr'});221 const cause = new Error(foobarString);222 stream.destroy(cause);223224 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 225–226why, one step back
225 assertStreamReadError(stream, {cause}),
226 assertStreamReadError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 227why, one step back
227 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 228–230why, one step back
228 assert.equal(error, secondError);
229 assert.equal(error.stderr, foobarString);230 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 231–232why, one step back
231});
232

TweaksSindre Sorhusbefore adoption698a1b8

line 233why, one step back
233test('Can error both .readable() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 234–241why, one step back
234 const subprocess = execa('noop-both.js', [foobarString]);
235 const stream = subprocess.readable();236 const secondStream = subprocess.readable({from: 'stderr'});237 const cause = new Error(foobarString);238 stream.destroy(cause);239 secondStream.destroy(cause);240241 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 242–243why, one step back
242 assertStreamReadError(stream, {cause}),
243 assertStreamReadError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 244why, one step back
244 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 245–246why, one step back
245 assert.equal(error, secondError);
246 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 247–248why, one step back
247});
248

TweaksSindre Sorhusbefore adoption698a1b8

line 249why, one step back
249test('Can error one of two .writable() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 250–257why, one step back
250 const subprocess = execa('stdin.js');
251 const stream = subprocess.writable();252 const secondStream = subprocess.writable();253 const cause = new Error(foobarString);254 stream.destroy(cause);255 secondStream.end(foobarString);256257 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

line 258why, one step back
258 assertStreamError(stream, cause),

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 259–260why, one step back
259 finishedStream(secondStream),
260 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 261why, one step back
261 await assertSubprocessOutput(subprocess);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 262–263why, one step back
262});
263

TweaksSindre Sorhusbefore adoption698a1b8

line 264why, one step back
264test('Can error both .writable() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 265–272why, one step back
265 const subprocess = execa('stdin.js');
266 const stream = subprocess.writable();267 const secondStream = subprocess.writable();268 const cause = new Error(foobarString);269 stream.destroy(cause);270 secondStream.destroy(cause);271272 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 273–274why, one step back
273 assertStreamError(stream, {cause}),
274 assertStreamError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 275why, one step back
275 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 276–277why, one step back
276 assert.equal(error, secondError);
277 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 278–279why, one step back
278});
279

TweaksSindre Sorhusbefore adoption698a1b8

line 280why, one step back
280test('Can error one of two .writable() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 281–288why, one step back
281 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());
282 const stream = subprocess.writable();283 const secondStream = subprocess.writable({to: 'fd3'});284 const cause = new Error(foobarString);285 stream.destroy(cause);286 secondStream.end(foobarString);287288 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 289–290why, one step back
289 assertStreamError(stream, {cause}),
290 assertStreamError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 291why, one step back
291 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 292–294why, one step back
292 assert.equal(error, secondError);
293 assert.equal(error.stdout, foobarString);294 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 295–296why, one step back
295});
296

TweaksSindre Sorhusbefore adoption698a1b8

line 297why, one step back
297test('Can error both .writable() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 298–305why, one step back
298 const subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());
299 const stream = subprocess.writable();300 const secondStream = subprocess.writable({to: 'fd3'});301 const cause = new Error(foobarString);302 stream.destroy(cause);303 secondStream.destroy(cause);304305 const [error, secondError] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 306–307why, one step back
306 assertStreamError(stream, {cause}),
307 assertStreamError(secondStream, {cause}),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 308why, one step back
308 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 309–310why, one step back
309 assert.equal(error, secondError);
310 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 311–312why, one step back
311});
312

TweaksSindre Sorhusbefore adoption698a1b8

line 313why, one step back
313test('Can error one of two .duplex() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 314–321why, one step back
314 const subprocess = execa('stdin.js');
315 const stream = subprocess.duplex();316 const secondStream = subprocess.duplex();317 const cause = new Error(foobarString);318 stream.destroy(cause);319 secondStream.end(foobarString);320321 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 322–323why, one step back
322 assertStreamReadError(stream, cause),
323 assertStreamOutput(secondStream),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 324why, one step back
324 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 325why, one step back
325 await assertSubprocessOutput(subprocess);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 326–327why, one step back
326});
327

TweaksSindre Sorhusbefore adoption698a1b8

line 328why, one step back
328test('Can error both .duplex() on same file descriptor', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 329–336why, one step back
329 const subprocess = execa('stdin.js');
330 const stream = subprocess.duplex();331 const secondStream = subprocess.duplex();332 const cause = new Error(foobarString);333 stream.destroy(cause);334 secondStream.destroy(cause);335336 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 337–338why, one step back
337 assertStreamReadError(stream, cause),
338 assertStreamReadError(secondStream, cause),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 339why, one step back
339 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 340why, one step back
340 await assertSubprocessError(subprocess, {cause});

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 341–342why, one step back
341});
342

TweaksSindre Sorhusbefore adoption698a1b8

line 343why, one step back
343test('Can error one of two .duplex() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 344–351why, one step back
344 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());
345 const stream = subprocess.duplex();346 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});347 const cause = new Error(foobarString);348 stream.destroy(cause);349 secondStream.end(foobarString);350351 const [error] = await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 352–353why, one step back
352 assertStreamReadError(secondStream, {cause}),
353 assertStreamReadError(stream, cause),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 354why, one step back
354 ]);

TweaksSindre Sorhusbefore adoption698a1b8

lines 355–356why, one step back
355 assert.equal(error.stderr, foobarString);
356 await assertSubprocessError(subprocess, error);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 357–358why, one step back
357});
358

TweaksSindre Sorhusbefore adoption698a1b8

line 359why, one step back
359test('Can error both .duplex() on different file descriptors', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 360–367why, one step back
360 const subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());
361 const stream = subprocess.duplex();362 const secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});363 const cause = new Error(foobarString);364 stream.destroy(cause);365 secondStream.destroy(cause);366367 await Promise.all([

TweaksSindre Sorhusbefore adoption698a1b8

lines 368–369why, one step back
368 assertStreamReadError(stream, cause),
369 assertStreamReadError(secondStream, cause),

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 370why, one step back
370 ]);

TweaksSindre Sorhusbefore adoption698a1b8

line 371why, one step back
371 await assertSubprocessError(subprocess, {cause});

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 372why, one step back
372});