Skip to content
Myr

split.js

This file

Path

test/stdio/split.js

339 lines · 31.0 KiB · JavaScript

Last changed by

Add support for `lines` option with `execaSync()` (#951)ehmickybefore adoption88bff1f

History of this file

Take it

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 1why, one step back
1import test from 'ava';

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 2why, one step back
2import {execa, execaSync} from '../../index.js';

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 3why, one step back
3import {setFixtureDir} from '../helpers/fixtures-dir.js';

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 4–8why, one step back
4import {getStdio} from '../helpers/stdio.js';
5import {6 getOutputsGenerator,7 noopGenerator,8 noopAsyncGenerator,

Refactor tests (#934)ehmickybefore adoption52c4bde

line 9why, one step back
9 resultGenerator,

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 10–14why, one step back
10} from '../helpers/generator.js';
11import {foobarString, foobarUint8Array, foobarObject, foobarObjectString} from '../helpers/input.js';12import {13 simpleFull,14 simpleChunks,

Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd

lines 15–16why, one step back
15 simpleFullUint8Array,
16 simpleChunksUint8Array,

Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf

line 17why, one step back
17 simpleFullHex,

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 18–19why, one step back
18 simpleLines,
19 simpleFullEndLines,

Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e

line 20why, one step back
20 noNewlinesFull,

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 21–22why, one step back
21 noNewlinesChunks,
22} from '../helpers/lines.js';

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 23–25why, one step back
23
24setFixtureDir();25

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 26–30why, one step back
26const simpleFullEnd = `${simpleFull}\n`;
27const simpleFullEndChunks = [simpleFullEnd];28const windowsFull = 'aaa\r\nbbb\r\nccc';29const windowsFullEnd = `${windowsFull}\r\n`;30const windowsChunks = [windowsFull];

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 31why, one step back
31const windowsLines = ['aaa\r\n', 'bbb\r\n', 'ccc'];

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 32why, one step back
32const noNewlinesFullEnd = `${noNewlinesFull}\n`;

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 33why, one step back
33const noNewlinesLines = ['aaabbbccc'];

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 34–45why, one step back
34const singleFull = 'aaa';
35const singleFullEnd = `${singleFull}\n`;36const singleFullEndWindows = `${singleFull}\r\n`;37const singleChunks = [singleFull];38const noLines = [];39const emptyFull = '';40const emptyChunks = [emptyFull];41const manyEmptyChunks = [emptyFull, emptyFull, emptyFull];42const newlineFull = '\n';43const newlineChunks = [newlineFull];44const newlinesFull = '\n\n\n';45const newlinesChunks = [newlinesFull];

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 46why, one step back
46const newlinesLines = ['\n', '\n', '\n'];

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 47–48why, one step back
47const windowsNewlinesFull = '\r\n\r\n\r\n';
48const windowsNewlinesChunks = [windowsNewlinesFull];

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 49–50why, one step back
49const windowsNewlinesLines = ['\r\n', '\r\n', '\r\n'];
50const runOverChunks = ['aaa\nb', 'b', 'b\nccc'];

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 51–53why, one step back
51const bigFull = '.'.repeat(1e5);
52const bigFullEnd = `${bigFull}\n`;53const bigChunks = [bigFull];

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 54why, one step back
54const manyChunks = Array.from({length: 1e3}).fill('.');

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 55–58why, one step back
55const manyFull = manyChunks.join('');
56const manyFullEnd = `${manyFull}\n`;57const manyLines = [manyFull];58const mixedNewlines = '.\n.\r\n.\n.\r\n.\n';

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 59–60why, one step back
59
60// eslint-disable-next-line max-params

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 61why, one step back
61const testLines = async (t, fdNumber, input, expectedLines, expectedOutput, objectMode, preserveNewlines, execaMethod) => {

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 62why, one step back
62 const lines = [];

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 63why, one step back
63 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], {

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 64why, one step back
64 ...getStdio(fdNumber, [

Refactor tests (#934)ehmickybefore adoption52c4bde

lines 65–66why, one step back
65 getOutputsGenerator(input)(false, true),
66 resultGenerator(lines)(objectMode, false, preserveNewlines),

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 67–69why, one step back
67 ]),
68 stripFinalNewline: false,69 });

Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd

lines 70–71why, one step back
70 t.deepEqual(lines, expectedLines);
71 t.deepEqual(stdio[fdNumber], expectedOutput);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 72–73why, one step back
72};
73

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 74–185why, one step back
74test('Split stdout - n newlines, 1 chunk', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execa);
75test('Split stderr - n newlines, 1 chunk', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execa);76test('Split stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execa);77test('Split stdout - preserveNewlines, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execa);78test('Split stdout - 0 newlines, 1 chunk', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execa);79test('Split stdout - empty, 1 chunk', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execa);80test('Split stdout - Windows newlines', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execa);81test('Split stdout - chunk ends with newline', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execa);82test('Split stdout - single newline', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execa);83test('Split stdout - only newlines', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execa);84test('Split stdout - only Windows newlines', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execa);85test('Split stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execa);86test('Split stdout - 0 newlines, big line', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execa);87test('Split stdout - 0 newlines, many chunks', testLines, 1, manyChunks, manyLines, manyFull, false, true, execa);88test('Split stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execa);89test('Split stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execa);90test('Split stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execa);91test('Split stdout - preserveNewlines, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execa);92test('Split stdout - empty, 1 chunk, objectMode', testLines, 1, emptyChunks, noLines, noLines, true, true, execa);93test('Split stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execa);94test('Split stdout - Windows newlines, objectMode', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execa);95test('Split stdout - chunk ends with newline, objectMode', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execa);96test('Split stdout - single newline, objectMode', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execa);97test('Split stdout - only newlines, objectMode', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execa);98test('Split stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execa);99test('Split stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execa);100test('Split stdout - 0 newlines, big line, objectMode', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execa);101test('Split stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, manyLines, manyLines, true, true, execa);102test('Split stdout - n newlines, 1 chunk, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);103test('Split stderr - n newlines, 1 chunk, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);104test('Split stdio[*] - n newlines, 1 chunk, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);105test('Split stdout - preserveNewlines, n chunks, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execa);106test('Split stdout - empty, 1 chunk, preserveNewlines', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execa);107test('Split stdout - 0 newlines, 1 chunk, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execa);108test('Split stdout - Windows newlines, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execa);109test('Split stdout - chunk ends with newline, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);110test('Split stdout - single newline, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execa);111test('Split stdout - only newlines, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execa);112test('Split stdout - only Windows newlines, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execa);113test('Split stdout - line split over multiple chunks, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);114test('Split stdout - 0 newlines, big line, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execa);115test('Split stdout - 0 newlines, many chunks, preserveNewlines', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execa);116test('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);117test('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);118test('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);119test('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execa);120test('Split stdout - empty, 1 chunk, objectMode, preserveNewlines', testLines, 1, emptyChunks, noLines, noLines, true, false, execa);121test('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execa);122test('Split stdout - Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);123test('Split stdout - chunk ends with newline, objectMode, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);124test('Split stdout - single newline, objectMode, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execa);125test('Split stdout - only newlines, objectMode, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);126test('Split stdout - only Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);127test('Split stdout - line split over multiple chunks, objectMode, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);128test('Split stdout - 0 newlines, big line, objectMode, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execa);129test('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines', testLines, 1, manyChunks, manyLines, manyLines, true, false, execa);130test('Split stdout - n newlines, 1 chunk, sync', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execaSync);131test('Split stderr - n newlines, 1 chunk, sync', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execaSync);132test('Split stdio[*] - n newlines, 1 chunk, sync', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execaSync);133test('Split stdout - preserveNewlines, n chunks, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execaSync);134test('Split stdout - 0 newlines, 1 chunk, sync', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execaSync);135test('Split stdout - empty, 1 chunk, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execaSync);136test('Split stdout - Windows newlines, sync', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execaSync);137test('Split stdout - chunk ends with newline, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execaSync);138test('Split stdout - single newline, sync', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execaSync);139test('Split stdout - only newlines, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execaSync);140test('Split stdout - only Windows newlines, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execaSync);141test('Split stdout - line split over multiple chunks, sync', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execaSync);142test('Split stdout - 0 newlines, big line, sync', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execaSync);143test('Split stdout - 0 newlines, many chunks, sync', testLines, 1, manyChunks, manyLines, manyFull, false, true, execaSync);144test('Split stdout - n newlines, 1 chunk, objectMode, sync', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execaSync);145test('Split stderr - n newlines, 1 chunk, objectMode, sync', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execaSync);146test('Split stdio[*] - n newlines, 1 chunk, objectMode, sync', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execaSync);147test('Split stdout - preserveNewlines, n chunks, objectMode, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execaSync);148test('Split stdout - empty, 1 chunk, objectMode, sync', testLines, 1, emptyChunks, noLines, noLines, true, true, execaSync);149test('Split stdout - 0 newlines, 1 chunk, objectMode, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execaSync);150test('Split stdout - Windows newlines, objectMode, sync', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execaSync);151test('Split stdout - chunk ends with newline, objectMode, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execaSync);152test('Split stdout - single newline, objectMode, sync', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execaSync);153test('Split stdout - only newlines, objectMode, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execaSync);154test('Split stdout - only Windows newlines, objectMode, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execaSync);155test('Split stdout - line split over multiple chunks, objectMode, sync', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execaSync);156test('Split stdout - 0 newlines, big line, objectMode, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execaSync);157test('Split stdout - 0 newlines, many chunks, objectMode, sync', testLines, 1, manyChunks, manyLines, manyLines, true, true, execaSync);158test('Split stdout - n newlines, 1 chunk, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);159test('Split stderr - n newlines, 1 chunk, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);160test('Split stdio[*] - n newlines, 1 chunk, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);161test('Split stdout - preserveNewlines, n chunks, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execaSync);162test('Split stdout - empty, 1 chunk, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execaSync);163test('Split stdout - 0 newlines, 1 chunk, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execaSync);164test('Split stdout - Windows newlines, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execaSync);165test('Split stdout - chunk ends with newline, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);166test('Split stdout - single newline, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execaSync);167test('Split stdout - only newlines, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execaSync);168test('Split stdout - only Windows newlines, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execaSync);169test('Split stdout - line split over multiple chunks, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);170test('Split stdout - 0 newlines, big line, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execaSync);171test('Split stdout - 0 newlines, many chunks, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execaSync);172test('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);173test('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);174test('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);175test('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execaSync);176test('Split stdout - empty, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, noLines, true, false, execaSync);177test('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execaSync);178test('Split stdout - Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);179test('Split stdout - chunk ends with newline, objectMode, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);180test('Split stdout - single newline, objectMode, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execaSync);181test('Split stdout - only newlines, objectMode, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);182test('Split stdout - only Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);183test('Split stdout - line split over multiple chunks, objectMode, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);184test('Split stdout - 0 newlines, big line, objectMode, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execaSync);185test('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyLines, true, false, execaSync);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 186–187why, one step back
186
187// eslint-disable-next-line max-params

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 188why, one step back
188const testBinaryOption = async (t, binary, input, expectedLines, expectedOutput, objectMode, preserveNewlines, encoding, execaMethod) => {

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 189why, one step back
189 const lines = [];

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 190why, one step back
190 const {stdout} = await execaMethod('noop.js', {

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 191why, one step back
191 stdout: [

Refactor tests (#934)ehmickybefore adoption52c4bde

lines 192–193why, one step back
192 getOutputsGenerator(input)(false, true),
193 resultGenerator(lines)(objectMode, binary, preserveNewlines),

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 194why, one step back
194 ],

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 195why, one step back
195 stripFinalNewline: false,

Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd

line 196why, one step back
196 encoding,

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 197–198why, one step back
197 });
198 t.deepEqual(lines, expectedLines);

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 199why, one step back
199 t.deepEqual(stdout, expectedOutput);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 200–201why, one step back
200};
201

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 202–241why, one step back
202test('Does not split lines when "binary" is true', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execa);
203test('Splits lines when "binary" is false', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);204test('Splits lines when "binary" is undefined', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);205test('Does not split lines when "binary" is undefined, encoding "buffer"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);206test('Does not split lines when "binary" is false, encoding "buffer"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);207test('Does not split lines when "binary" is undefined, encoding "hex"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);208test('Does not split lines when "binary" is false, encoding "hex"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);209test('Does not split lines when "binary" is true, objectMode', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execa);210test('Splits lines when "binary" is false, objectMode', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);211test('Splits lines when "binary" is undefined, objectMode', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);212test('Does not split lines when "binary" is true, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execa);213test('Splits lines when "binary" is false, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);214test('Splits lines when "binary" is undefined, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);215test('Does not split lines when "binary" is undefined, encoding "buffer", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);216test('Does not split lines when "binary" is false, encoding "buffer", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);217test('Does not split lines when "binary" is true, objectMode, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execa);218test('Does not split lines when "binary" is undefined, encoding "hex", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);219test('Does not split lines when "binary" is false, encoding "hex", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);220test('Splits lines when "binary" is false, objectMode, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);221test('Splits lines when "binary" is undefined, objectMode, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);222test('Does not split lines when "binary" is true, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execaSync);223test('Splits lines when "binary" is false, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);224test('Splits lines when "binary" is undefined, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);225test('Does not split lines when "binary" is undefined, encoding "buffer", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);226test('Does not split lines when "binary" is false, encoding "buffer", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);227test('Does not split lines when "binary" is undefined, encoding "hex", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);228test('Does not split lines when "binary" is false, encoding "hex", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);229test('Does not split lines when "binary" is true, objectMode, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execaSync);230test('Splits lines when "binary" is false, objectMode, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);231test('Splits lines when "binary" is undefined, objectMode, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);232test('Does not split lines when "binary" is true, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execaSync);233test('Splits lines when "binary" is false, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);234test('Splits lines when "binary" is undefined, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);235test('Does not split lines when "binary" is undefined, encoding "buffer", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);236test('Does not split lines when "binary" is false, encoding "buffer", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);237test('Does not split lines when "binary" is true, objectMode, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execaSync);238test('Does not split lines when "binary" is undefined, encoding "hex", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);239test('Does not split lines when "binary" is false, encoding "hex", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);240test('Splits lines when "binary" is false, objectMode, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);241test('Splits lines when "binary" is undefined, objectMode, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 242why, one step back
242

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 243–245why, one step back
243const resultUint8ArrayGenerator = function * (lines, chunk) {
244 lines.push(chunk);245 yield new TextEncoder().encode(chunk);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

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

Add support for `lines` option with `execaSync()` (#951)ehmickybefore adoption88bff1f

lines 248–249why, one step back
248// eslint-disable-next-line max-params
249const testStringToUint8Array = async (t, expectedOutput, objectMode, preserveNewlines, execaMethod) => {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 250why, one step back
250 const lines = [];

Add support for `lines` option with `execaSync()` (#951)ehmickybefore adoption88bff1f

line 251why, one step back
251 const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 252–261why, one step back
252 stdout: {
253 transform: resultUint8ArrayGenerator.bind(undefined, lines),254 objectMode,255 preserveNewlines,256 },257 lines: true,258 });259 t.deepEqual(lines, [foobarString]);260 t.deepEqual(stdout, expectedOutput);261};

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 262why, one step back
262

Add support for `lines` option with `execaSync()` (#951)ehmickybefore adoption88bff1f

lines 263–270why, one step back
263test('Line splitting when converting from string to Uint8Array', testStringToUint8Array, [foobarString], false, true, execa);
264test('Line splitting when converting from string to Uint8Array, objectMode', testStringToUint8Array, [foobarUint8Array], true, true, execa);265test('Line splitting when converting from string to Uint8Array, preserveNewlines', testStringToUint8Array, [foobarString], false, false, execa);266test('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines', testStringToUint8Array, [foobarUint8Array], true, false, execa);267test('Line splitting when converting from string to Uint8Array, sync', testStringToUint8Array, [foobarString], false, true, execaSync);268test('Line splitting when converting from string to Uint8Array, objectMode, sync', testStringToUint8Array, [foobarUint8Array], true, true, execaSync);269test('Line splitting when converting from string to Uint8Array, preserveNewlines, sync', testStringToUint8Array, [foobarString], false, false, execaSync);270test('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines, sync', testStringToUint8Array, [foobarUint8Array], true, false, execaSync);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 271why, one step back
271

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 272–273why, one step back
272const testStripNewline = async (t, input, expectedOutput, execaMethod) => {
273 const {stdout} = await execaMethod('noop.js', {

Refactor tests (#934)ehmickybefore adoption52c4bde

line 274why, one step back
274 stdout: getOutputsGenerator([input])(),

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 275–277why, one step back
275 stripFinalNewline: false,
276 });277 t.is(stdout, expectedOutput);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

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

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 280–285why, one step back
280test('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd, execa);
281test('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd, execa);282test('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows, execa);283test('Strips newline when user do not mistakenly yield one at the end, sync', testStripNewline, singleFull, singleFullEnd, execaSync);284test('Strips newline when user mistakenly yielded one at the end, sync', testStripNewline, singleFullEnd, singleFullEnd, execaSync);285test('Strips newline when user mistakenly yielded one at the end, Windows newline, sync', testStripNewline, singleFullEndWindows, singleFullEndWindows, execaSync);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 286why, one step back
286

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 287–288why, one step back
287const testMixNewlines = async (t, generator, execaMethod) => {
288 const {stdout} = await execaMethod('noop-fd.js', ['1', mixedNewlines], {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 289–293why, one step back
289 stdout: generator(),
290 stripFinalNewline: false,291 });292 t.is(stdout, mixedNewlines);293};

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 294why, one step back
294

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 295–297why, one step back
295test('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator, execa);
296test('Can mix Unix and Windows newlines, sync', testMixNewlines, noopGenerator, execaSync);297test('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator, execa);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 298why, one step back
298

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 299–301why, one step back
299const serializeResultGenerator = function * (lines, chunk) {
300 lines.push(chunk);301 yield JSON.stringify(chunk);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 302–303why, one step back
302};
303

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 304why, one step back
304const testUnsetObjectMode = async (t, expectedOutput, preserveNewlines, execaMethod) => {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 305why, one step back
305 const lines = [];

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 306why, one step back
306 const {stdout} = await execaMethod('noop.js', {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 307why, one step back
307 stdout: [

Refactor tests (#934)ehmickybefore adoption52c4bde

line 308why, one step back
308 getOutputsGenerator([foobarObject])(true),

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 309–314why, one step back
309 {transform: serializeResultGenerator.bind(undefined, lines), preserveNewlines, objectMode: false},
310 ],311 stripFinalNewline: false,312 });313 t.deepEqual(lines, [foobarObject]);314 t.is(stdout, expectedOutput);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 315–316why, one step back
315};
316

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 317–320why, one step back
317test('Can switch from objectMode to non-objectMode', testUnsetObjectMode, `${foobarObjectString}\n`, false, execa);
318test('Can switch from objectMode to non-objectMode, preserveNewlines', testUnsetObjectMode, foobarObjectString, true, execa);319test('Can switch from objectMode to non-objectMode, sync', testUnsetObjectMode, `${foobarObjectString}\n`, false, execaSync);320test('Can switch from objectMode to non-objectMode, preserveNewlines, sync', testUnsetObjectMode, foobarObjectString, true, execaSync);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 321why, one step back
321

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 322–323why, one step back
322// eslint-disable-next-line max-params
323const testYieldArray = async (t, input, expectedLines, expectedOutput, execaMethod) => {

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 324why, one step back
324 const lines = [];

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

line 325why, one step back
325 const {stdout} = await execaMethod('noop.js', {

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

line 326why, one step back
326 stdout: [

Refactor tests (#934)ehmickybefore adoption52c4bde

lines 327–328why, one step back
327 getOutputsGenerator(input)(),
328 resultGenerator(lines)(),

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 329–330why, one step back
329 ],
330 stripFinalNewline: false,

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

line 331why, one step back
331 });

Strip newlines in transforms (#919)ehmickybefore adoption26e9150

lines 332–333why, one step back
332 t.deepEqual(lines, expectedLines);
333 t.deepEqual(stdout, expectedOutput);

Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c

lines 334–335why, one step back
334};
335

Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09

lines 336–339why, one step back
336test('Can use "yield* array" to produce multiple lines', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execa);
337test('Can use "yield* array" to produce empty lines', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execa);338test('Can use "yield* array" to produce multiple lines, sync', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execaSync);339test('Can use "yield* array" to produce empty lines, sync', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execaSync);