split.js
This file
Path
test/stdio/split.js
334 lines · 30.3 KiB · JavaScript
Last changed by
Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
History of this fileTake it
Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 1why, one step back1import test from 'ava';Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 2why, one step back2import {execa, execaSync} from '../../index.js';Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 3why, one step back3import {setFixtureDir} from '../helpers/fixtures-dir.js';Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 4–8why, one step back4import {getStdio} from '../helpers/stdio.js';5import {6 getOutputsGenerator,7 noopGenerator,8 noopAsyncGenerator,Refactor tests (#934)ehmickybefore adoption52c4bde
line 9why, one step back9 resultGenerator,Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 10–14why, one step back10} 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 back15 simpleFullUint8Array,16 simpleChunksUint8Array,Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 17why, one step back17 simpleFullHex,Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 18–19why, one step back18 simpleLines,19 simpleFullEndLines,Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 20why, one step back20 noNewlinesFull,Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 21–22why, one step back21 noNewlinesChunks,22} from '../helpers/lines.js';Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 23–25why, one step back2324setFixtureDir();25Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 26–30why, one step back26const 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 back31const windowsLines = ['aaa\r\n', 'bbb\r\n', 'ccc'];Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 32why, one step back32const noNewlinesFullEnd = `${noNewlinesFull}\n`;Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 33why, one step back33const noNewlinesLines = ['aaabbbccc'];Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 34–45why, one step back34const 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 back46const newlinesLines = ['\n', '\n', '\n'];Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 47–48why, one step back47const 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 back49const 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 back51const bigFull = '.'.repeat(1e5);52const bigFullEnd = `${bigFull}\n`;53const bigChunks = [bigFull];Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 54why, one step back54const manyChunks = Array.from({length: 1e3}).fill('.');Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 55–58why, one step back55const 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 back5960// eslint-disable-next-line max-paramsAdd support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 61why, one step back61const testLines = async (t, fdNumber, input, expectedLines, expectedOutput, objectMode, preserveNewlines, execaMethod) => {Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 62why, one step back62 const lines = [];Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 63why, one step back63 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], {Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 64why, one step back64 ...getStdio(fdNumber, [Refactor tests (#934)ehmickybefore adoption52c4bde
lines 65–66why, one step back65 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 back67 ]),68 stripFinalNewline: false,69 });Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 70–71why, one step back70 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 back72};73Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 74–185why, one step back74test('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 back186187// eslint-disable-next-line max-paramsAdd support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 188why, one step back188const 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 back189 const lines = [];Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 190why, one step back190 const {stdout} = await execaMethod('noop.js', {Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 191why, one step back191 stdout: [Refactor tests (#934)ehmickybefore adoption52c4bde
lines 192–193why, one step back192 getOutputsGenerator(input)(false, true),193 resultGenerator(lines)(objectMode, binary, preserveNewlines),Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 194why, one step back194 ],Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 195why, one step back195 stripFinalNewline: false,Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 196why, one step back196 encoding,Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 197–198why, one step back197 });198 t.deepEqual(lines, expectedLines);Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 199why, one step back199 t.deepEqual(stdout, expectedOutput);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 200–201why, one step back200};201Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 202–241why, one step back202test('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 back242Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 243–245why, one step back243const 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 back246};247Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 248–260why, one step back248const testStringToUint8Array = async (t, expectedOutput, objectMode, preserveNewlines) => {249 const lines = [];250 const {stdout} = await execa('noop-fd.js', ['1', foobarString], {251 stdout: {252 transform: resultUint8ArrayGenerator.bind(undefined, lines),253 objectMode,254 preserveNewlines,255 },256 lines: true,257 });258 t.deepEqual(lines, [foobarString]);259 t.deepEqual(stdout, expectedOutput);260};Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 261why, one step back261Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 262–265why, one step back262test('Line splitting when converting from string to Uint8Array', testStringToUint8Array, [foobarString], false, true);263test('Line splitting when converting from string to Uint8Array, objectMode', testStringToUint8Array, [foobarUint8Array], true, true);264test('Line splitting when converting from string to Uint8Array, preserveNewlines', testStringToUint8Array, [foobarString], false, false);265test('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines', testStringToUint8Array, [foobarUint8Array], true, false);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 266why, one step back266Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 267–268why, one step back267const testStripNewline = async (t, input, expectedOutput, execaMethod) => {268 const {stdout} = await execaMethod('noop.js', {Refactor tests (#934)ehmickybefore adoption52c4bde
line 269why, one step back269 stdout: getOutputsGenerator([input])(),Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 270–272why, one step back270 stripFinalNewline: false,271 });272 t.is(stdout, expectedOutput);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 273–274why, one step back273};274Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 275–280why, one step back275test('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd, execa);276test('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd, execa);277test('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows, execa);278test('Strips newline when user do not mistakenly yield one at the end, sync', testStripNewline, singleFull, singleFullEnd, execaSync);279test('Strips newline when user mistakenly yielded one at the end, sync', testStripNewline, singleFullEnd, singleFullEnd, execaSync);280test('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 281why, one step back281Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 282–283why, one step back282const testMixNewlines = async (t, generator, execaMethod) => {283 const {stdout} = await execaMethod('noop-fd.js', ['1', mixedNewlines], {Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 284–288why, one step back284 stdout: generator(),285 stripFinalNewline: false,286 });287 t.is(stdout, mixedNewlines);288};Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 289why, one step back289Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 290–292why, one step back290test('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator, execa);291test('Can mix Unix and Windows newlines, sync', testMixNewlines, noopGenerator, execaSync);292test('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator, execa);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 293why, one step back293Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 294–296why, one step back294const serializeResultGenerator = function * (lines, chunk) {295 lines.push(chunk);296 yield JSON.stringify(chunk);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 297–298why, one step back297};298Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 299why, one step back299const testUnsetObjectMode = async (t, expectedOutput, preserveNewlines, execaMethod) => {Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 300why, one step back300 const lines = [];Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 301why, one step back301 const {stdout} = await execaMethod('noop.js', {Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 302why, one step back302 stdout: [Refactor tests (#934)ehmickybefore adoption52c4bde
line 303why, one step back303 getOutputsGenerator([foobarObject])(true),Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 304–309why, one step back304 {transform: serializeResultGenerator.bind(undefined, lines), preserveNewlines, objectMode: false},305 ],306 stripFinalNewline: false,307 });308 t.deepEqual(lines, [foobarObject]);309 t.is(stdout, expectedOutput);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 310–311why, one step back310};311Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 312–315why, one step back312test('Can switch from objectMode to non-objectMode', testUnsetObjectMode, `${foobarObjectString}\n`, false, execa);313test('Can switch from objectMode to non-objectMode, preserveNewlines', testUnsetObjectMode, foobarObjectString, true, execa);314test('Can switch from objectMode to non-objectMode, sync', testUnsetObjectMode, `${foobarObjectString}\n`, false, execaSync);315test('Can switch from objectMode to non-objectMode, preserveNewlines, sync', testUnsetObjectMode, foobarObjectString, true, execaSync);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 316why, one step back316Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 317–318why, one step back317// eslint-disable-next-line max-params318const testYieldArray = async (t, input, expectedLines, expectedOutput, execaMethod) => {Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 319why, one step back319 const lines = [];Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 320why, one step back320 const {stdout} = await execaMethod('noop.js', {Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 321why, one step back321 stdout: [Refactor tests (#934)ehmickybefore adoption52c4bde
lines 322–323why, one step back322 getOutputsGenerator(input)(),323 resultGenerator(lines)(),Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 324–325why, one step back324 ],325 stripFinalNewline: false,Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 326why, one step back326 });Strip newlines in transforms (#919)ehmickybefore adoption26e9150
lines 327–328why, one step back327 t.deepEqual(lines, expectedLines);328 t.deepEqual(stdout, expectedOutput);Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 329–330why, one step back329};330Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 331–334why, one step back331test('Can use "yield* array" to produce multiple lines', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execa);332test('Can use "yield* array" to produce empty lines', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execa);333test('Can use "yield* array" to produce multiple lines, sync', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\n${foobarString}\n`, execaSync);334test('Can use "yield* array" to produce empty lines, sync', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\n\n`, execaSync);