encoding-transform.js
This file
Path
test/stdio/encoding-transform.js
294 lines · 31.9 KiB · JavaScript
Last changed by
Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
History of this fileTake it
Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 1–2why, one step back1import {Buffer} from 'node:buffer';2import test from 'ava';Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 3why, one step back3import {execa, execaSync} from '../../index.js';Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 4–6why, one step back4import {setFixtureDir} from '../helpers/fixtures-dir.js';5import {getStdio} from '../helpers/stdio.js';6import {foobarString, foobarUint8Array, foobarBuffer, foobarObject} from '../helpers/input.js';Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 7why, one step back7import {noopGenerator, getOutputGenerator, getOutputsGenerator, convertTransformToFinal} from '../helpers/generator.js';Add `binary` and `preserveNewlines` options to `subprocess.readable()` (#922)ehmickybefore adoption56ee48e
line 8why, one step back8import {multibyteChar, multibyteString, multibyteUint8Array, breakingLength, brokenSymbol} from '../helpers/encoding.js';Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 9–11why, one step back910setFixtureDir();11Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 12why, one step back12const getTypeofGenerator = (objectMode, binary) => ({Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 13–16why, one step back13 * transform(line) {14 yield Object.prototype.toString.call(line);15 },16 objectMode,Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 17why, one step back17 binary,Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 18–19why, one step back18});19Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 20–24why, one step back20const assertTypeofChunk = (t, output, encoding, expectedType) => {21 const typeofChunk = Buffer.from(output, encoding === 'buffer' ? undefined : encoding).toString().trim();22 t.is(typeofChunk, `[object ${expectedType}]`);23};24Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 25why, one step back25// eslint-disable-next-line max-paramsPrevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 26–27why, one step back26const testGeneratorFirstEncoding = async (t, input, encoding, expectedType, objectMode, binary) => {27 const subprocess = execa('stdin.js', {stdin: getTypeofGenerator(objectMode, binary), encoding});Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 28–29why, one step back28 subprocess.stdin.end(input);29 const {stdout} = await subprocess;Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 30why, one step back30 assertTypeofChunk(t, stdout, encoding, expectedType);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 31–32why, one step back31};32Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 33–38why, one step back33test('First generator argument is string with default encoding, with string writes', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', false);34test('First generator argument is string with default encoding, with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'utf8', 'String', false);35test('First generator argument is string with default encoding, with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'utf8', 'String', false);36test('First generator argument is Uint8Array with encoding "buffer", with string writes', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false);37test('First generator argument is Uint8Array with encoding "buffer", with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'buffer', 'Uint8Array', false);38test('First generator argument is Uint8Array with encoding "buffer", with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'buffer', 'Uint8Array', false);Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
lines 39–41why, one step back39test('First generator argument is Uint8Array with encoding "hex", with string writes', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false);40test('First generator argument is Uint8Array with encoding "hex", with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'hex', 'Uint8Array', false);41test('First generator argument is Uint8Array with encoding "hex", with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'hex', 'Uint8Array', false);Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 42–47why, one step back42test('First generator argument can be string with objectMode', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', true);43test('First generator argument can be objects with objectMode', testGeneratorFirstEncoding, foobarObject, 'utf8', 'Object', true);44test('First generator argument is string with default encoding, with string writes, "binary: false"', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', false, false);45test('First generator argument is Uint8Array with default encoding, with string writes, "binary: true"', testGeneratorFirstEncoding, foobarString, 'utf8', 'Uint8Array', false, true);46test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: false"', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, false);47test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: true"', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, true);Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 48why, one step back48test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: false"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, false);Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 49why, one step back49test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: true"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, true);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 50why, one step back50Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 51–71why, one step back51// eslint-disable-next-line max-params52const testGeneratorFirstEncodingSync = (t, input, encoding, expectedType, objectMode, binary) => {53 const {stdout} = execaSync('stdin.js', {stdin: [[input], getTypeofGenerator(objectMode, binary)], encoding});54 assertTypeofChunk(t, stdout, encoding, expectedType);55};5657test('First generator argument is string with default encoding, with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false);58test('First generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'utf8', 'String', false);59test('First generator argument is Uint8Array with encoding "buffer", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false);60test('First generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'buffer', 'Uint8Array', false);61test('First generator argument is Uint8Array with encoding "hex", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false);62test('First generator argument is Uint8Array with encoding "hex", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'hex', 'Uint8Array', false);63test('First generator argument can be string with objectMode, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', true);64test('First generator argument can be objects with objectMode, sync', testGeneratorFirstEncodingSync, foobarObject, 'utf8', 'Object', true);65test('First generator argument is string with default encoding, with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false, false);66test('First generator argument is Uint8Array with default encoding, with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'Uint8Array', false, true);67test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, false);68test('First generator argument is Uint8Array with encoding "buffer", with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, true);69test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: false", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, false);70test('First generator argument is Uint8Array with encoding "hex", with string writes, "binary: true", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, true);71Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 72–73why, one step back72const testEncodingIgnored = async (t, encoding) => {73 const input = Buffer.from(foobarString).toString(encoding);Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 74–76why, one step back74 const subprocess = execa('stdin.js', {stdin: noopGenerator(true)});75 subprocess.stdin.end(input, encoding);76 const {stdout} = await subprocess;Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 77–85why, one step back77 t.is(stdout, input);78};7980test('Write call encoding "utf8" is ignored with objectMode', testEncodingIgnored, 'utf8');81test('Write call encoding "utf16le" is ignored with objectMode', testEncodingIgnored, 'utf16le');82test('Write call encoding "hex" is ignored with objectMode', testEncodingIgnored, 'hex');83test('Write call encoding "base64" is ignored with objectMode', testEncodingIgnored, 'base64');8485// eslint-disable-next-line max-paramsAdd support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 86–87why, one step back86const testGeneratorNextEncoding = async (t, input, encoding, firstObjectMode, secondObjectMode, expectedType, execaMethod) => {87 const {stdout} = await execaMethod('noop.js', ['other'], {Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 88why, one step back88 stdout: [Refactor tests (#934)ehmickybefore adoption52c4bde
line 89why, one step back89 getOutputGenerator(input)(firstObjectMode),Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 90why, one step back90 getTypeofGenerator(secondObjectMode),Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 91–93why, one step back91 ],92 encoding,93 });Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
lines 94–95why, one step back94 const output = Array.isArray(stdout) ? stdout[0] : stdout;95 assertTypeofChunk(t, output, encoding, expectedType);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 96–97why, one step back96};97Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 98–129why, one step back98test('Next generator argument is string with default encoding, with string writes', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execa);99test('Next generator argument is string with default encoding, with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execa);100test('Next generator argument is string with default encoding, with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execa);101test('Next generator argument is string with default encoding, with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execa);102test('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execa);103test('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execa);104test('Next generator argument is Uint8Array with encoding "buffer", with string writes', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execa);105test('Next generator argument is string with encoding "buffer", with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execa);106test('Next generator argument is string with encoding "buffer", with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execa);107test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execa);108test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execa);109test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execa);110test('Next generator argument is Uint8Array with encoding "hex", with string writes', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execa);111test('Next generator argument is Uint8Array with encoding "hex", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execa);112test('Next generator argument is object with default encoding, with object writes, objectMode first', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execa);113test('Next generator argument is object with default encoding, with object writes, objectMode both', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execa);114test('Next generator argument is string with default encoding, with string writes, sync', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execaSync);115test('Next generator argument is string with default encoding, with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execaSync);116test('Next generator argument is string with default encoding, with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execaSync);117test('Next generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execaSync);118test('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execaSync);119test('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execaSync);120test('Next generator argument is Uint8Array with encoding "buffer", with string writes, sync', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execaSync);121test('Next generator argument is string with encoding "buffer", with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execaSync);122test('Next generator argument is string with encoding "buffer", with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execaSync);123test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execaSync);124test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execaSync);125test('Next generator argument is Uint8Array with encoding "buffer", with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execaSync);126test('Next generator argument is Uint8Array with encoding "hex", with string writes, sync', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execaSync);127test('Next generator argument is Uint8Array with encoding "hex", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execaSync);128test('Next generator argument is object with default encoding, with object writes, objectMode first, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execaSync);129test('Next generator argument is object with default encoding, with object writes, objectMode both, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execaSync);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 130why, one step back130Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 131–132why, one step back131const testFirstOutputGeneratorArgument = async (t, fdNumber, execaMethod) => {132 const {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, getTypeofGenerator(true)));Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 133–135why, one step back133 t.deepEqual(stdio[fdNumber], ['[object String]']);134};135Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 136–141why, one step back136test('The first generator with result.stdout does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 1, execa);137test('The first generator with result.stderr does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 2, execa);138test('The first generator with result.stdio[*] does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 3, execa);139test('The first generator with result.stdout does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 1, execaSync);140test('The first generator with result.stderr does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 2, execaSync);141test('The first generator with result.stdio[*] does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 3, execaSync);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 142–143why, one step back142143// eslint-disable-next-line max-paramsAdd support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 144why, one step back144const testGeneratorReturnType = async (t, input, encoding, reject, objectMode, final, execaMethod) => {Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 145why, one step back145 const fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
line 146why, one step back146 const {stdout} = await execaMethod(fixtureName, ['1', foobarString], {Refactor tests (#934)ehmickybefore adoption52c4bde
line 147why, one step back147 stdout: convertTransformToFinal(getOutputGenerator(input)(objectMode, true), final),Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 148–151why, one step back148 encoding,149 reject,150 });151 const typeofChunk = Array.isArray(stdout) ? stdout[0] : stdout;Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
line 152why, one step back152 const output = Buffer.from(typeofChunk, encoding === 'buffer' || objectMode ? undefined : encoding).toString();Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 153–155why, one step back153 t.is(output, foobarString);154};155Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 156–251why, one step back156test('Generator can return string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execa);157test('Generator can return Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execa);158test('Generator can return string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execa);159test('Generator can return Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execa);160test('Generator can return string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, false, execa);161test('Generator can return Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execa);162test('Generator can return string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execa);163test('Generator can return Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execa);164test('Generator can return string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execa);165test('Generator can return Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execa);166test('Generator can return string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, false, execa);167test('Generator can return Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execa);168test('Generator can return string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execa);169test('Generator can return Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execa);170test('Generator can return string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execa);171test('Generator can return Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execa);172test('Generator can return string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, false, execa);173test('Generator can return Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execa);174test('Generator can return string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execa);175test('Generator can return Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execa);176test('Generator can return string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execa);177test('Generator can return Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execa);178test('Generator can return string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, false, execa);179test('Generator can return Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execa);180test('Generator can return final string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execa);181test('Generator can return final Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execa);182test('Generator can return final string with encoding "buffer"', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execa);183test('Generator can return final Uint8Array with encoding "buffer"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execa);184test('Generator can return final string with encoding "hex"', testGeneratorReturnType, foobarString, 'hex', true, false, true, execa);185test('Generator can return final Uint8Array with encoding "hex"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execa);186test('Generator can return final string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execa);187test('Generator can return final Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execa);188test('Generator can return final string with encoding "buffer", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execa);189test('Generator can return final Uint8Array with encoding "buffer", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execa);190test('Generator can return final string with encoding "hex", failure', testGeneratorReturnType, foobarString, 'hex', false, false, true, execa);191test('Generator can return final Uint8Array with encoding "hex", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execa);192test('Generator can return final string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execa);193test('Generator can return final Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execa);194test('Generator can return final string with encoding "buffer", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execa);195test('Generator can return final Uint8Array with encoding "buffer", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execa);196test('Generator can return final string with encoding "hex", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, true, execa);197test('Generator can return final Uint8Array with encoding "hex", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execa);198test('Generator can return final string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execa);199test('Generator can return final Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execa);200test('Generator can return final string with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execa);201test('Generator can return final Uint8Array with encoding "buffer", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execa);202test('Generator can return final string with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, true, execa);203test('Generator can return final Uint8Array with encoding "hex", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execa);204test('Generator can return string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execaSync);205test('Generator can return Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execaSync);206test('Generator can return string with encoding "buffer", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execaSync);207test('Generator can return Uint8Array with encoding "buffer", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execaSync);208test('Generator can return string with encoding "hex", sync', testGeneratorReturnType, foobarString, 'hex', true, false, false, execaSync);209test('Generator can return Uint8Array with encoding "hex", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execaSync);210test('Generator can return string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execaSync);211test('Generator can return Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execaSync);212test('Generator can return string with encoding "buffer", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execaSync);213test('Generator can return Uint8Array with encoding "buffer", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execaSync);214test('Generator can return string with encoding "hex", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, false, execaSync);215test('Generator can return Uint8Array with encoding "hex", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execaSync);216test('Generator can return string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execaSync);217test('Generator can return Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execaSync);218test('Generator can return string with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execaSync);219test('Generator can return Uint8Array with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execaSync);220test('Generator can return string with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, false, execaSync);221test('Generator can return Uint8Array with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execaSync);222test('Generator can return string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execaSync);223test('Generator can return Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execaSync);224test('Generator can return string with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execaSync);225test('Generator can return Uint8Array with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execaSync);226test('Generator can return string with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, false, execaSync);227test('Generator can return Uint8Array with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execaSync);228test('Generator can return final string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execaSync);229test('Generator can return final Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execaSync);230test('Generator can return final string with encoding "buffer", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execaSync);231test('Generator can return final Uint8Array with encoding "buffer", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execaSync);232test('Generator can return final string with encoding "hex", sync', testGeneratorReturnType, foobarString, 'hex', true, false, true, execaSync);233test('Generator can return final Uint8Array with encoding "hex", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execaSync);234test('Generator can return final string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execaSync);235test('Generator can return final Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execaSync);236test('Generator can return final string with encoding "buffer", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execaSync);237test('Generator can return final Uint8Array with encoding "buffer", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execaSync);238test('Generator can return final string with encoding "hex", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, true, execaSync);239test('Generator can return final Uint8Array with encoding "hex", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execaSync);240test('Generator can return final string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execaSync);241test('Generator can return final Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execaSync);242test('Generator can return final string with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execaSync);243test('Generator can return final Uint8Array with encoding "buffer", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execaSync);244test('Generator can return final string with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, true, execaSync);245test('Generator can return final Uint8Array with encoding "hex", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execaSync);246test('Generator can return final string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execaSync);247test('Generator can return final Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execaSync);248test('Generator can return final string with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execaSync);249test('Generator can return final Uint8Array with encoding "buffer", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execaSync);250test('Generator can return final string with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, true, execaSync);251test('Generator can return final Uint8Array with encoding "hex", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execaSync);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 252why, one step back252Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 253–259why, one step back253const testMultibyte = async (t, objectMode, execaMethod) => {254 const {stdout} = await execaMethod('stdin.js', {255 stdin: [256 [multibyteUint8Array.slice(0, breakingLength), multibyteUint8Array.slice(breakingLength)],257 noopGenerator(objectMode, true),258 ],259 });Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 260–262why, one step back260 t.is(stdout, multibyteString);261};262Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 263–266why, one step back263test('Generator handles multibyte characters with Uint8Array', testMultibyte, false, execa);264test('Generator handles multibyte characters with Uint8Array, objectMode', testMultibyte, true, execa);265test('Generator handles multibyte characters with Uint8Array, sync', testMultibyte, false, execaSync);266test('Generator handles multibyte characters with Uint8Array, objectMode, sync', testMultibyte, true, execaSync);Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
line 267why, one step back267Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 268–269why, one step back268const testMultibytePartial = async (t, objectMode, execaMethod) => {269 const {stdout} = await execaMethod('stdin.js', {Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 270–271why, one step back270 stdin: [271 [multibyteUint8Array.slice(0, breakingLength)],Strip newlines in transforms (#919)ehmickybefore adoption26e9150
line 272why, one step back272 noopGenerator(objectMode, true),Fix strings returned by transforms in `objectMode` (#917)ehmickybefore adoption98f403c
lines 273–274why, one step back273 ],274 });Rename 2 files with wrong file names (#865)ehmickybefore adoption4bd0fe3
lines 275–277why, one step back275 t.is(stdout, `${multibyteChar}${brokenSymbol}`);276};277Add support for transforms with `execaSync()` (#945)ehmickybefore adoptionc5f9f09
lines 278–294why, one step back278test('Generator handles partial multibyte characters with Uint8Array', testMultibytePartial, false, execa);279test('Generator handles partial multibyte characters with Uint8Array, objectMode', testMultibytePartial, true, execa);280test('Generator handles partial multibyte characters with Uint8Array, sync', testMultibytePartial, false, execaSync);281test('Generator handles partial multibyte characters with Uint8Array, objectMode, sync', testMultibytePartial, true, execaSync);282283const testMultibytePartialOutput = async (t, execaMethod) => {284 const {stdout} = await execaMethod('noop.js', {285 stdout: getOutputsGenerator([286 multibyteUint8Array.slice(0, breakingLength),287 multibyteUint8Array.slice(breakingLength),288 ])(false, true),289 });290 t.is(stdout, multibyteString);291};292293test('Generator handles output multibyte characters with Uint8Array', testMultibytePartialOutput, execa);294test('Generator handles output multibyte characters with Uint8Array, sync', testMultibytePartialOutput, execaSync);