Skip to content
Myr

all.js

This file

Path

test/resolve/all.js

284 lines · 21.3 KiB · JavaScript

Last changed by

Fix errors, early errors and `result.all` edge casesSindre Sorhusbefore adoptionc4262ff

History of this file

Take it

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

Fix errors, early errors and `result.all` edge casesSindre Sorhusbefore adoptionc4262ff

line 1why, one step back
1import {Buffer} from 'node:buffer';

TweaksSindre Sorhusbefore adoption698a1b8

lines 2–3why, one step back
2import assert from 'node:assert/strict';
3import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–6why, one step back
4import {execa, execaSync} from '../../index.js';
5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {defaultHighWaterMark} from '../helpers/stream.js';

Fix errors, early errors and `result.all` edge casesSindre Sorhusbefore adoptionc4262ff

lines 7–8why, one step back
7import {foobarString, foobarObject} from '../helpers/input.js';
8import {outputObjectGenerator} from '../helpers/generator.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 9–21why, one step back
9
10setFixtureDirectory();1112const textEncoder = new TextEncoder();13const foobarStringFull = `${foobarString}\n`;14const doubleFoobarStringFull = `${foobarStringFull}${foobarStringFull}`;15const doubleFoobarString = `${foobarStringFull}${foobarString}`;16const doubleFoobarUint8ArrayFull = textEncoder.encode(doubleFoobarStringFull);17const doubleFoobarUint8Array = textEncoder.encode(doubleFoobarString);18const doubleFoobarArrayFull = [foobarStringFull, foobarStringFull];19const doubleFoobarArray = [foobarString, foobarString];2021// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 22why, one step back
22const testAllBoth = async (expectedOutput, encoding, lines, stripFinalNewline, isFailure, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 23–30why, one step back
23 const fixtureName = isFailure ? 'noop-both-fail.js' : 'noop-both.js';
24 const {exitCode, all} = await execaMethod(fixtureName, [foobarString], {25 all: true,26 encoding,27 lines,28 stripFinalNewline,29 reject: !isFailure,30 });

TweaksSindre Sorhusbefore adoption698a1b8

lines 31–32why, one step back
31 assert.equal(exitCode, isFailure ? 1 : 0);
32 assert.deepEqual(all, expectedOutput);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 33–34why, one step back
33};
34

Fix errors, early errors and `result.all` edge casesSindre Sorhusbefore adoptionc4262ff

lines 35–59why, one step back
35// With encodings like base64, the bytes must be merged before being encoded, otherwise the padding of the first output would end up in the middle
36const testAllBinaryEncoding = (encoding, execaMethod) => testAllBoth(Buffer.from(doubleFoobarStringFull).toString(encoding), encoding, false, false, false, execaMethod);3738test('result.all is defined, encoding "base64"', () => testAllBinaryEncoding('base64', execa));39test('result.all is defined, encoding "base64url"', () => testAllBinaryEncoding('base64url', execa));40test('result.all is defined, encoding "hex"', () => testAllBinaryEncoding('hex', execa));41test('result.all is defined, encoding "latin1"', () => testAllBinaryEncoding('latin1', execa));42test('result.all is defined, encoding "base64", sync', () => testAllBinaryEncoding('base64', execaSync));43test('result.all is defined, encoding "base64url", sync', () => testAllBinaryEncoding('base64url', execaSync));44test('result.all is defined, encoding "hex", sync', () => testAllBinaryEncoding('hex', execaSync));45test('result.all is defined, encoding "latin1", sync', () => testAllBinaryEncoding('latin1', execaSync));4647// An empty output is not interleaved with the objects of the other file descriptor48const testAllObjectModeEmpty = async (fixtureName, commandArguments, options, expectedAll) => {49 const {all} = await execa(fixtureName, commandArguments, {...options, all: true});50 assert.deepEqual(all, expectedAll);51 const {all: allSync} = execaSync(fixtureName, commandArguments, {...options, all: true});52 assert.deepEqual(allSync, expectedAll);53};5455test('result.all omits empty stderr with objectMode stdout', () => testAllObjectModeEmpty('noop.js', [foobarString], {stdout: outputObjectGenerator()}, [foobarObject]));56test('result.all omits empty stdout with objectMode stderr', () => testAllObjectModeEmpty('noop-fd.js', ['2', foobarString], {stderr: outputObjectGenerator()}, [foobarObject]));57test('result.all omits empty stderr with objectMode stdout, encoding "buffer"', () => testAllObjectModeEmpty('noop.js', [foobarString], {stdout: outputObjectGenerator(), encoding: 'buffer'}, [foobarObject]));58test('result.all keeps non-empty stderr with objectMode stdout', () => testAllObjectModeEmpty('noop-both.js', [foobarString], {stdout: outputObjectGenerator()}, [foobarObject, `${foobarString}\n`]));59

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 60–62why, one step back
60const fdOne = {stderr: true};
61const fdBoth = {stdout: true, stderr: true};62

TweaksSindre Sorhusbefore adoption698a1b8

lines 63–126why, one step back
63test('result.all is defined', () => testAllBoth(doubleFoobarStringFull, 'utf8', false, false, false, execa));
64test('result.all is defined, encoding "buffer"', () => testAllBoth(doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execa));65test('result.all is defined, lines', () => testAllBoth(doubleFoobarArrayFull, 'utf8', true, false, false, execa));66test('result.all is defined, lines, fd-specific one', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdOne, false, false, execa));67test('result.all is defined, lines, fd-specific both', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdBoth, false, false, execa));68test('result.all is defined, stripFinalNewline', () => testAllBoth(doubleFoobarString, 'utf8', false, true, false, execa));69test('result.all is defined, stripFinalNewline, fd-specific one', () => testAllBoth(doubleFoobarString, 'utf8', false, fdOne, false, execa));70test('result.all is defined, stripFinalNewline, fd-specific both', () => testAllBoth(doubleFoobarString, 'utf8', false, fdBoth, false, execa));71test('result.all is defined, encoding "buffer", stripFinalNewline', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, true, false, execa));72test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific one', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdOne, false, execa));73test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific both', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdBoth, false, execa));74test('result.all is defined, lines, stripFinalNewline', () => testAllBoth(doubleFoobarArray, 'utf8', true, true, false, execa));75test('result.all is defined, lines, fd-specific one, stripFinalNewline', () => testAllBoth(doubleFoobarArray, 'utf8', fdOne, true, false, execa));76test('result.all is defined, lines, fd-specific both, stripFinalNewline', () => testAllBoth(doubleFoobarArray, 'utf8', fdBoth, true, false, execa));77test('result.all is defined, lines, stripFinalNewline, fd-specific one', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdOne, false, execa));78test('result.all is defined, lines, stripFinalNewline, fd-specific both', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdBoth, false, execa));79test('result.all is defined, failure', () => testAllBoth(doubleFoobarStringFull, 'utf8', false, false, true, execa));80test('result.all is defined, encoding "buffer", failure', () => testAllBoth(doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execa));81test('result.all is defined, lines, failure', () => testAllBoth(doubleFoobarArrayFull, 'utf8', true, false, true, execa));82test('result.all is defined, lines, fd-specific one, failure', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdOne, false, true, execa));83test('result.all is defined, lines, fd-specific both, failure', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdBoth, false, true, execa));84test('result.all is defined, stripFinalNewline, failure', () => testAllBoth(doubleFoobarString, 'utf8', false, true, true, execa));85test('result.all is defined, stripFinalNewline, fd-specific one, failure', () => testAllBoth(doubleFoobarString, 'utf8', false, fdOne, true, execa));86test('result.all is defined, stripFinalNewline, fd-specific both, failure', () => testAllBoth(doubleFoobarString, 'utf8', false, fdBoth, true, execa));87test('result.all is defined, encoding "buffer", stripFinalNewline, failure', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, true, true, execa));88test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific one, failure', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdOne, true, execa));89test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific both, failure', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdBoth, true, execa));90test('result.all is defined, lines, stripFinalNewline, failure', () => testAllBoth(doubleFoobarArray, 'utf8', true, true, true, execa));91test('result.all is defined, lines, fd-specific one, stripFinalNewline, failure', () => testAllBoth(doubleFoobarArray, 'utf8', fdOne, true, true, execa));92test('result.all is defined, lines, fd-specific both, stripFinalNewline, failure', () => testAllBoth(doubleFoobarArray, 'utf8', fdBoth, true, true, execa));93test('result.all is defined, lines, stripFinalNewline, fd-specific one, failure', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdOne, true, execa));94test('result.all is defined, lines, stripFinalNewline, fd-specific both, failure', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdBoth, true, execa));95test('result.all is defined, sync', () => testAllBoth(doubleFoobarStringFull, 'utf8', false, false, false, execaSync));96test('result.all is defined, encoding "buffer", sync', () => testAllBoth(doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execaSync));97test('result.all is defined, lines, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', true, false, false, execaSync));98test('result.all is defined, lines, fd-specific one, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdOne, false, false, execaSync));99test('result.all is defined, lines, fd-specific both, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdBoth, false, false, execaSync));100test('result.all is defined, stripFinalNewline, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, true, false, execaSync));101test('result.all is defined, stripFinalNewline, fd-specific one, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, fdOne, false, execaSync));102test('result.all is defined, stripFinalNewline, fd-specific both, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, fdBoth, false, execaSync));103test('result.all is defined, encoding "buffer", stripFinalNewline, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, true, false, execaSync));104test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific one, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdOne, false, execaSync));105test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific both, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdBoth, false, execaSync));106test('result.all is defined, lines, stripFinalNewline, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, true, false, execaSync));107test('result.all is defined, lines, fd-specific one, stripFinalNewline, sync', () => testAllBoth(doubleFoobarArray, 'utf8', fdOne, true, false, execaSync));108test('result.all is defined, lines, fd-specific both, stripFinalNewline, sync', () => testAllBoth(doubleFoobarArray, 'utf8', fdBoth, true, false, execaSync));109test('result.all is defined, lines, stripFinalNewline, fd-specific one, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdOne, false, execaSync));110test('result.all is defined, lines, stripFinalNewline, fd-specific both, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdBoth, false, execaSync));111test('result.all is defined, failure, sync', () => testAllBoth(doubleFoobarStringFull, 'utf8', false, false, true, execaSync));112test('result.all is defined, encoding "buffer", failure, sync', () => testAllBoth(doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execaSync));113test('result.all is defined, lines, failure, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', true, false, true, execaSync));114test('result.all is defined, lines, fd-specific one, failure, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdOne, false, true, execaSync));115test('result.all is defined, lines, fd-specific both, failure, sync', () => testAllBoth(doubleFoobarArrayFull, 'utf8', fdBoth, false, true, execaSync));116test('result.all is defined, stripFinalNewline, failure, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, true, true, execaSync));117test('result.all is defined, stripFinalNewline, fd-specific one, failure, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, fdOne, true, execaSync));118test('result.all is defined, stripFinalNewline, fd-specific both, failure, sync', () => testAllBoth(doubleFoobarString, 'utf8', false, fdBoth, true, execaSync));119test('result.all is defined, encoding "buffer", stripFinalNewline, failure, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, true, true, execaSync));120test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific one, failure, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdOne, true, execaSync));121test('result.all is defined, encoding "buffer", stripFinalNewline, fd-specific both, failure, sync', () => testAllBoth(doubleFoobarUint8Array, 'buffer', false, fdBoth, true, execaSync));122test('result.all is defined, lines, stripFinalNewline, failure, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, true, true, execaSync));123test('result.all is defined, lines, fd-specific one, stripFinalNewline, failure, sync', () => testAllBoth(doubleFoobarArray, 'utf8', fdOne, true, true, execaSync));124test('result.all is defined, lines, fd-specific both, stripFinalNewline, failure, sync', () => testAllBoth(doubleFoobarArray, 'utf8', fdBoth, true, true, execaSync));125test('result.all is defined, lines, stripFinalNewline, fd-specific one, failure, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdOne, true, execaSync));126test('result.all is defined, lines, stripFinalNewline, fd-specific both, failure, sync', () => testAllBoth(doubleFoobarArray, 'utf8', true, fdBoth, true, execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 127why, one step back
127

TweaksSindre Sorhusbefore adoption698a1b8

line 128why, one step back
128test('result.all shows both `stdout` and `stderr` intermixed', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 129why, one step back
129 const {all} = await execa('noop-132.js', {all: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 130why, one step back
130 assert.equal(all, '1\n2\n3');

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 133why, one step back
133test('result.all shows both `stdout` and `stderr` not intermixed, sync', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 134why, one step back
134 const {all} = execaSync('noop-132.js', {all: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 135why, one step back
135 assert.equal(all, '1\n3\n2');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 136–137why, one step back
136});
137

TweaksSindre Sorhusbefore adoption698a1b8

line 138why, one step back
138const testAllIgnored = async (options, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 139why, one step back
139 const {all} = await execaMethod('noop.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 140why, one step back
140 assert.equal(all, undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 141–142why, one step back
141};
142

TweaksSindre Sorhusbefore adoption698a1b8

lines 143–148why, one step back
143test('result.all is undefined unless opts.all is true', () => testAllIgnored({}, execa));
144test('result.all is undefined if opts.all is false', () => testAllIgnored({all: false}, execa));145test('result.all is undefined if ignored', () => testAllIgnored({stdio: 'ignore', all: true}, execa));146test('result.all is undefined unless opts.all is true, sync', () => testAllIgnored({}, execaSync));147test('result.all is undefined if opts.all is false, sync', () => testAllIgnored({all: false}, execaSync));148test('result.all is undefined if ignored, sync', () => testAllIgnored({stdio: 'ignore', all: true}, execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 149why, one step back
149

TweaksSindre Sorhusbefore adoption698a1b8

line 150why, one step back
150const testAllProperties = async options => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 151why, one step back
151 const subprocess = execa('empty.js', {...options, all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 152–153why, one step back
152 assert.equal(subprocess.all.readableObjectMode, false);
153 assert.equal(subprocess.all.readableHighWaterMark, defaultHighWaterMark);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 154–156why, one step back
154 await subprocess;
155};156

TweaksSindre Sorhusbefore adoption698a1b8

lines 157–159why, one step back
157test('subprocess.all has the right objectMode and highWaterMark - stdout + stderr', () => testAllProperties({}));
158test('subprocess.all has the right objectMode and highWaterMark - stdout only', () => testAllProperties({stderr: 'ignore'}));159test('subprocess.all has the right objectMode and highWaterMark - stderr only', () => testAllProperties({stdout: 'ignore'}));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 160why, one step back
160

TweaksSindre Sorhusbefore adoption698a1b8

line 161why, one step back
161const testAllIgnore = async (streamName, otherStreamName) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 162why, one step back
162 const subprocess = execa('noop-both.js', {[otherStreamName]: 'ignore', all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 163–167why, one step back
163 assert.equal(subprocess[otherStreamName], null);
164 assert.notEqual(subprocess[streamName], null);165 assert.notEqual(subprocess.all, null);166 assert.equal(subprocess.all.readableObjectMode, subprocess[streamName].readableObjectMode);167 assert.equal(subprocess.all.readableHighWaterMark, subprocess[streamName].readableHighWaterMark);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 168–169why, one step back
168
169 const result = await subprocess;

TweaksSindre Sorhusbefore adoption698a1b8

lines 170–172why, one step back
170 assert.equal(result[otherStreamName], undefined);
171 assert.equal(result[streamName], foobarString);172 assert.equal(result.all, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 173–174why, one step back
173};
174

TweaksSindre Sorhusbefore adoption698a1b8

lines 175–176why, one step back
175test('can use all: true with stdout: ignore', () => testAllIgnore('stderr', 'stdout'));
176test('can use all: true with stderr: ignore', () => testAllIgnore('stdout', 'stderr'));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 177why, one step back
177

TweaksSindre Sorhusbefore adoption698a1b8

line 178why, one step back
178const testAllIgnoreSync = (streamName, otherStreamName) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 179why, one step back
179 const result = execaSync('noop-both.js', {[otherStreamName]: 'ignore', all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 180–182why, one step back
180 assert.equal(result[otherStreamName], undefined);
181 assert.equal(result[streamName], foobarString);182 assert.equal(result.all, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 183–184why, one step back
183};
184

TweaksSindre Sorhusbefore adoption698a1b8

lines 185–186why, one step back
185test('can use all: true with stdout: ignore, sync', () => testAllIgnoreSync('stderr', 'stdout'));
186test('can use all: true with stderr: ignore, sync', () => testAllIgnoreSync('stdout', 'stderr'));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 187why, one step back
187

TweaksSindre Sorhusbefore adoption698a1b8

line 188why, one step back
188test('can use all: true with stdout: ignore + stderr: ignore', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 189why, one step back
189 const subprocess = execa('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 190–192why, one step back
190 assert.equal(subprocess.stdout, null);
191 assert.equal(subprocess.stderr, null);192 assert.equal(subprocess.all, undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 193–194why, one step back
193
194 const {stdout, stderr, all} = await subprocess;

TweaksSindre Sorhusbefore adoption698a1b8

lines 195–197why, one step back
195 assert.equal(stdout, undefined);
196 assert.equal(stderr, undefined);197 assert.equal(all, undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 200why, one step back
200test('can use all: true with stdout: ignore + stderr: ignore, sync', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 201why, one step back
201 const {stdout, stderr, all} = execaSync('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});

TweaksSindre Sorhusbefore adoption698a1b8

lines 202–204why, one step back
202 assert.equal(stdout, undefined);
203 assert.equal(stderr, undefined);204 assert.equal(all, undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 205why, one step back
205});

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 206–210why, one step back
206
207// `all` is split into lines when the `lines` option applies to either file descriptor, even when only one of them uses it208const foobarTwoLines = `${foobarString}\n${foobarString}`;209// The fixture writes the same two lines to both `stdout` and `stderr`210const foobarTwoLinesArray = Array.from({length: 4}, () => `${foobarString}\n`);

TweaksSindre Sorhusbefore adoption698a1b8

line 211why, one step back
211const testAllBothLines = async (lines, execaMethod) => {

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

line 212why, one step back
212 const {all} = await execaMethod('noop-both.js', [foobarTwoLines], {all: true, lines, stripFinalNewline: false});

TweaksSindre Sorhusbefore adoption698a1b8

line 213why, one step back
213 assert.deepEqual(all, foobarTwoLinesArray);

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 214–215why, one step back
214};
215

TweaksSindre Sorhusbefore adoption698a1b8

lines 216–219why, one step back
216test('result.all is split into lines when only stdout uses the lines option', () => testAllBothLines({stdout: true}, execa));
217test('result.all is split into lines when only stderr uses the lines option', () => testAllBothLines({stderr: true}, execa));218test('result.all is split into lines when only stdout uses the lines option, sync', () => testAllBothLines({stdout: true}, execaSync));219test('result.all is split into lines when only stderr uses the lines option, sync', () => testAllBothLines({stderr: true}, execaSync));

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 220–221why, one step back
220
221// When only one file descriptor is interleaved into `all`, it must follow that one exactly, including its `stripFinalNewline` value

TweaksSindre Sorhusbefore adoption698a1b8

line 222why, one step back
222const testAllOneFd = async (lines, execaMethod) => {

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 223–228why, one step back
223 const {stderr, all} = await execaMethod('noop-both.js', [foobarString], {
224 all: true,225 stdout: 'ignore',226 lines,227 stripFinalNewline: {stderr: false},228 });

TweaksSindre Sorhusbefore adoption698a1b8

lines 229–230why, one step back
229 assert.deepEqual(stderr, lines ? [`${foobarString}\n`] : `${foobarString}\n`);
230 assert.deepEqual(all, stderr);

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 233–236why, one step back
233test('result.all follows stderr when stdout is ignored', () => testAllOneFd(false, execa));
234test('result.all follows stderr when stdout is ignored, lines', () => testAllOneFd(true, execa));235test('result.all follows stderr when stdout is ignored, sync', () => testAllOneFd(false, execaSync));236test('result.all follows stderr when stdout is ignored, lines, sync', () => testAllOneFd(true, execaSync));

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 237–238why, one step back
237
238// `all` is split into lines as soon as the `lines` option applies to either file descriptor, even the one which is not interleaved into `all`

TweaksSindre Sorhusbefore adoption698a1b8

line 239why, one step back
239const testAllOneFdOtherLines = async (linesFdName, ignoredFdName, stripFinalNewline, execaMethod) => {

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 240–245why, one step back
240 const {all} = await execaMethod('noop-both.js', [foobarString], {
241 all: true,242 [ignoredFdName]: 'ignore',243 lines: {[linesFdName]: true},244 stripFinalNewline,245 });

TweaksSindre Sorhusbefore adoption698a1b8

line 246why, one step back
246 assert.deepEqual(all, [stripFinalNewline ? foobarString : `${foobarString}\n`]);

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 249–270why, one step back
249test('result.all is split into lines when only stdout uses the lines option and stderr is ignored', () => testAllOneFdOtherLines('stdout', 'stderr', true, execa));
250test('result.all is split into lines when only stdout uses the lines option and stderr is ignored, stripFinalNewline false', () => testAllOneFdOtherLines('stdout', 'stderr', false, execa));251test('result.all is split into lines when only stderr uses the lines option and stdout is ignored', () => testAllOneFdOtherLines('stderr', 'stdout', true, execa));252test('result.all is split into lines when only stdout uses the lines option and stderr is ignored, sync', () => testAllOneFdOtherLines('stdout', 'stderr', true, execaSync));253test('result.all is split into lines when only stderr uses the lines option and stdout is ignored, sync', () => testAllOneFdOtherLines('stderr', 'stdout', true, execaSync));254255// `splitLinesSync()` passes a non-string chunk straight through, so an absent file descriptor256// must not be split, or it would be reported as a line holding `undefined`.257const testAllNoFd = async (lines, execaMethod) => {258 const {all} = await execaMethod('noop.js', [], {259 all: true,260 lines,261 stdout: 'ignore',262 stderr: 'ignore',263 });264 assert.equal(all, undefined);265};266267test('result.all is undefined when no file descriptor is buffered', () => testAllNoFd(false, execa));268test('result.all is undefined when no file descriptor is buffered, lines', () => testAllNoFd(true, execa));269test('result.all is undefined when no file descriptor is buffered, sync', () => testAllNoFd(false, execaSync));270test('result.all is undefined when no file descriptor is buffered, lines, sync', () => testAllNoFd(true, execaSync));

Fix errors, early errors and `result.all` edge casesSindre Sorhusbefore adoptionc4262ff

lines 271–284why, one step back
271
272const testUtf16LinesAll = async execaMethod => {273 const script = 'process.stdout.write(Buffer.from(\'a\\r\\nb\\n\', \'utf16le\')); process.stderr.write(Buffer.from(\'c\\n\', \'utf16le\'))';274 const {all} = await execaMethod('node', ['-e', script], {275 all: true,276 lines: true,277 encoding: 'utf16le',278 stripFinalNewline: false,279 });280 assert.deepEqual(all, ['a\r\n', 'b\n', 'c\n']);281};282283test('result.all splits lines with utf16le encoding', () => testUtf16LinesAll(execa));284test('result.all splits lines with utf16le encoding, sync', () => testUtf16LinesAll(execaSync));