Skip to content
Myr

generator-input.js

This file

Path

test/transform/generator-input.js

159 lines · 17.0 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 08eb743 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

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

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

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

TweaksSindre Sorhusbefore adoption698a1b8

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

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 4–32why, one step back
4import {execa, execaSync} from '../../index.js';
5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {getStdio} from '../helpers/stdio.js';7import {8 foobarString,9 foobarUppercase,10 foobarHex,11 foobarUint8Array,12 foobarBuffer,13 foobarObject,14 foobarObjectString,15} from '../helpers/input.js';16import {generatorsMap} from '../helpers/map.js';1718setFixtureDirectory();1920const getInputObjectMode = (objectMode, addNoopTransform, type) => objectMode21 ? {22 input: [foobarObject],23 generators: generatorsMap[type].addNoop(generatorsMap[type].serialize(objectMode), addNoopTransform, objectMode),24 output: foobarObjectString,25 }26 : {27 input: foobarUint8Array,28 generators: generatorsMap[type].addNoop(generatorsMap[type].uppercase(objectMode), addNoopTransform, objectMode),29 output: foobarUppercase,30 };3132// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 33why, one step back
33const testGeneratorInput = async (fdNumber, objectMode, addNoopTransform, type, execaMethod) => {

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 34–35why, one step back
34 const {input, generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);
35 const {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [input, ...generators]));

TweaksSindre Sorhusbefore adoption698a1b8

line 36why, one step back
36 assert.equal(stdout, output);

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 37–38why, one step back
37};
38

TweaksSindre Sorhusbefore adoption698a1b8

lines 39–66why, one step back
39test('Can use generators with result.stdin', () => testGeneratorInput(0, false, false, 'generator', execa));
40test('Can use generators with result.stdio[*] as input', () => testGeneratorInput(3, false, false, 'generator', execa));41test('Can use generators with result.stdin, objectMode', () => testGeneratorInput(0, true, false, 'generator', execa));42test('Can use generators with result.stdio[*] as input, objectMode', () => testGeneratorInput(3, true, false, 'generator', execa));43test('Can use generators with result.stdin, noop transform', () => testGeneratorInput(0, false, true, 'generator', execa));44test('Can use generators with result.stdio[*] as input, noop transform', () => testGeneratorInput(3, false, true, 'generator', execa));45test('Can use generators with result.stdin, objectMode, noop transform', () => testGeneratorInput(0, true, true, 'generator', execa));46test('Can use generators with result.stdio[*] as input, objectMode, noop transform', () => testGeneratorInput(3, true, true, 'generator', execa));47test('Can use generators with result.stdin, sync', () => testGeneratorInput(0, false, false, 'generator', execaSync));48test('Can use generators with result.stdin, objectMode, sync', () => testGeneratorInput(0, true, false, 'generator', execaSync));49test('Can use generators with result.stdin, noop transform, sync', () => testGeneratorInput(0, false, true, 'generator', execaSync));50test('Can use generators with result.stdin, objectMode, noop transform, sync', () => testGeneratorInput(0, true, true, 'generator', execaSync));51test('Can use duplexes with result.stdin', () => testGeneratorInput(0, false, false, 'duplex', execa));52test('Can use duplexes with result.stdio[*] as input', () => testGeneratorInput(3, false, false, 'duplex', execa));53test('Can use duplexes with result.stdin, objectMode', () => testGeneratorInput(0, true, false, 'duplex', execa));54test('Can use duplexes with result.stdio[*] as input, objectMode', () => testGeneratorInput(3, true, false, 'duplex', execa));55test('Can use duplexes with result.stdin, noop transform', () => testGeneratorInput(0, false, true, 'duplex', execa));56test('Can use duplexes with result.stdio[*] as input, noop transform', () => testGeneratorInput(3, false, true, 'duplex', execa));57test('Can use duplexes with result.stdin, objectMode, noop transform', () => testGeneratorInput(0, true, true, 'duplex', execa));58test('Can use duplexes with result.stdio[*] as input, objectMode, noop transform', () => testGeneratorInput(3, true, true, 'duplex', execa));59test('Can use webTransforms with result.stdin', () => testGeneratorInput(0, false, false, 'webTransform', execa));60test('Can use webTransforms with result.stdio[*] as input', () => testGeneratorInput(3, false, false, 'webTransform', execa));61test('Can use webTransforms with result.stdin, objectMode', () => testGeneratorInput(0, true, false, 'webTransform', execa));62test('Can use webTransforms with result.stdio[*] as input, objectMode', () => testGeneratorInput(3, true, false, 'webTransform', execa));63test('Can use webTransforms with result.stdin, noop transform', () => testGeneratorInput(0, false, true, 'webTransform', execa));64test('Can use webTransforms with result.stdio[*] as input, noop transform', () => testGeneratorInput(3, false, true, 'webTransform', execa));65test('Can use webTransforms with result.stdin, objectMode, noop transform', () => testGeneratorInput(0, true, true, 'webTransform', execa));66test('Can use webTransforms with result.stdio[*] as input, objectMode, noop transform', () => testGeneratorInput(3, true, true, 'webTransform', execa));

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 67–68why, one step back
67
68// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 69why, one step back
69const testGeneratorInputPipe = async (useShortcutProperty, objectMode, addNoopTransform, type, input) => {

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 70–75why, one step back
70 const {generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);
71 const subprocess = execa('stdin-fd.js', ['0'], getStdio(0, generators));72 const stream = useShortcutProperty ? subprocess.stdin : subprocess.stdio[0];73 stream.end(...input);74 const {stdout} = await subprocess;75 const expectedOutput = input[1] === 'utf16le' ? Buffer.from(output, input[1]).toString() : output;

TweaksSindre Sorhusbefore adoption698a1b8

line 76why, one step back
76 assert.equal(stdout, expectedOutput);

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 77–78why, one step back
77};
78

TweaksSindre Sorhusbefore adoption698a1b8

lines 79–138why, one step back
79test('Can use generators with subprocess.stdio[0] and default encoding', () => testGeneratorInputPipe(false, false, false, 'generator', [foobarString, 'utf8']));
80test('Can use generators with subprocess.stdin and default encoding', () => testGeneratorInputPipe(true, false, false, 'generator', [foobarString, 'utf8']));81test('Can use generators with subprocess.stdio[0] and encoding "utf16le"', () => testGeneratorInputPipe(false, false, false, 'generator', [foobarString, 'utf16le']));82test('Can use generators with subprocess.stdin and encoding "utf16le"', () => testGeneratorInputPipe(true, false, false, 'generator', [foobarString, 'utf16le']));83test('Can use generators with subprocess.stdio[0] and encoding "buffer"', () => testGeneratorInputPipe(false, false, false, 'generator', [foobarBuffer, 'buffer']));84test('Can use generators with subprocess.stdin and encoding "buffer"', () => testGeneratorInputPipe(true, false, false, 'generator', [foobarBuffer, 'buffer']));85test('Can use generators with subprocess.stdio[0] and encoding "hex"', () => testGeneratorInputPipe(false, false, false, 'generator', [foobarHex, 'hex']));86test('Can use generators with subprocess.stdin and encoding "hex"', () => testGeneratorInputPipe(true, false, false, 'generator', [foobarHex, 'hex']));87test('Can use generators with subprocess.stdio[0], objectMode', () => testGeneratorInputPipe(false, true, false, 'generator', [foobarObject]));88test('Can use generators with subprocess.stdin, objectMode', () => testGeneratorInputPipe(true, true, false, 'generator', [foobarObject]));89test('Can use generators with subprocess.stdio[0] and default encoding, noop transform', () => testGeneratorInputPipe(false, false, true, 'generator', [foobarString, 'utf8']));90test('Can use generators with subprocess.stdin and default encoding, noop transform', () => testGeneratorInputPipe(true, false, true, 'generator', [foobarString, 'utf8']));91test('Can use generators with subprocess.stdio[0] and encoding "utf16le", noop transform', () => testGeneratorInputPipe(false, false, true, 'generator', [foobarString, 'utf16le']));92test('Can use generators with subprocess.stdin and encoding "utf16le", noop transform', () => testGeneratorInputPipe(true, false, true, 'generator', [foobarString, 'utf16le']));93test('Can use generators with subprocess.stdio[0] and encoding "buffer", noop transform', () => testGeneratorInputPipe(false, false, true, 'generator', [foobarBuffer, 'buffer']));94test('Can use generators with subprocess.stdin and encoding "buffer", noop transform', () => testGeneratorInputPipe(true, false, true, 'generator', [foobarBuffer, 'buffer']));95test('Can use generators with subprocess.stdio[0] and encoding "hex", noop transform', () => testGeneratorInputPipe(false, false, true, 'generator', [foobarHex, 'hex']));96test('Can use generators with subprocess.stdin and encoding "hex", noop transform', () => testGeneratorInputPipe(true, false, true, 'generator', [foobarHex, 'hex']));97test('Can use generators with subprocess.stdio[0], objectMode, noop transform', () => testGeneratorInputPipe(false, true, true, 'generator', [foobarObject]));98test('Can use generators with subprocess.stdin, objectMode, noop transform', () => testGeneratorInputPipe(true, true, true, 'generator', [foobarObject]));99test('Can use duplexes with subprocess.stdio[0] and default encoding', () => testGeneratorInputPipe(false, false, false, 'duplex', [foobarString, 'utf8']));100test('Can use duplexes with subprocess.stdin and default encoding', () => testGeneratorInputPipe(true, false, false, 'duplex', [foobarString, 'utf8']));101test('Can use duplexes with subprocess.stdio[0] and encoding "utf16le"', () => testGeneratorInputPipe(false, false, false, 'duplex', [foobarString, 'utf16le']));102test('Can use duplexes with subprocess.stdin and encoding "utf16le"', () => testGeneratorInputPipe(true, false, false, 'duplex', [foobarString, 'utf16le']));103test('Can use duplexes with subprocess.stdio[0] and encoding "buffer"', () => testGeneratorInputPipe(false, false, false, 'duplex', [foobarBuffer, 'buffer']));104test('Can use duplexes with subprocess.stdin and encoding "buffer"', () => testGeneratorInputPipe(true, false, false, 'duplex', [foobarBuffer, 'buffer']));105test('Can use duplexes with subprocess.stdio[0] and encoding "hex"', () => testGeneratorInputPipe(false, false, false, 'duplex', [foobarHex, 'hex']));106test('Can use duplexes with subprocess.stdin and encoding "hex"', () => testGeneratorInputPipe(true, false, false, 'duplex', [foobarHex, 'hex']));107test('Can use duplexes with subprocess.stdio[0], objectMode', () => testGeneratorInputPipe(false, true, false, 'duplex', [foobarObject]));108test('Can use duplexes with subprocess.stdin, objectMode', () => testGeneratorInputPipe(true, true, false, 'duplex', [foobarObject]));109test('Can use duplexes with subprocess.stdio[0] and default encoding, noop transform', () => testGeneratorInputPipe(false, false, true, 'duplex', [foobarString, 'utf8']));110test('Can use duplexes with subprocess.stdin and default encoding, noop transform', () => testGeneratorInputPipe(true, false, true, 'duplex', [foobarString, 'utf8']));111test('Can use duplexes with subprocess.stdio[0] and encoding "utf16le", noop transform', () => testGeneratorInputPipe(false, false, true, 'duplex', [foobarString, 'utf16le']));112test('Can use duplexes with subprocess.stdin and encoding "utf16le", noop transform', () => testGeneratorInputPipe(true, false, true, 'duplex', [foobarString, 'utf16le']));113test('Can use duplexes with subprocess.stdio[0] and encoding "buffer", noop transform', () => testGeneratorInputPipe(false, false, true, 'duplex', [foobarBuffer, 'buffer']));114test('Can use duplexes with subprocess.stdin and encoding "buffer", noop transform', () => testGeneratorInputPipe(true, false, true, 'duplex', [foobarBuffer, 'buffer']));115test('Can use duplexes with subprocess.stdio[0] and encoding "hex", noop transform', () => testGeneratorInputPipe(false, false, true, 'duplex', [foobarHex, 'hex']));116test('Can use duplexes with subprocess.stdin and encoding "hex", noop transform', () => testGeneratorInputPipe(true, false, true, 'duplex', [foobarHex, 'hex']));117test('Can use duplexes with subprocess.stdio[0], objectMode, noop transform', () => testGeneratorInputPipe(false, true, true, 'duplex', [foobarObject]));118test('Can use duplexes with subprocess.stdin, objectMode, noop transform', () => testGeneratorInputPipe(true, true, true, 'duplex', [foobarObject]));119test('Can use webTransforms with subprocess.stdio[0] and default encoding', () => testGeneratorInputPipe(false, false, false, 'webTransform', [foobarString, 'utf8']));120test('Can use webTransforms with subprocess.stdin and default encoding', () => testGeneratorInputPipe(true, false, false, 'webTransform', [foobarString, 'utf8']));121test('Can use webTransforms with subprocess.stdio[0] and encoding "utf16le"', () => testGeneratorInputPipe(false, false, false, 'webTransform', [foobarString, 'utf16le']));122test('Can use webTransforms with subprocess.stdin and encoding "utf16le"', () => testGeneratorInputPipe(true, false, false, 'webTransform', [foobarString, 'utf16le']));123test('Can use webTransforms with subprocess.stdio[0] and encoding "buffer"', () => testGeneratorInputPipe(false, false, false, 'webTransform', [foobarBuffer, 'buffer']));124test('Can use webTransforms with subprocess.stdin and encoding "buffer"', () => testGeneratorInputPipe(true, false, false, 'webTransform', [foobarBuffer, 'buffer']));125test('Can use webTransforms with subprocess.stdio[0] and encoding "hex"', () => testGeneratorInputPipe(false, false, false, 'webTransform', [foobarHex, 'hex']));126test('Can use webTransforms with subprocess.stdin and encoding "hex"', () => testGeneratorInputPipe(true, false, false, 'webTransform', [foobarHex, 'hex']));127test('Can use webTransforms with subprocess.stdio[0], objectMode', () => testGeneratorInputPipe(false, true, false, 'webTransform', [foobarObject]));128test('Can use webTransforms with subprocess.stdin, objectMode', () => testGeneratorInputPipe(true, true, false, 'webTransform', [foobarObject]));129test('Can use webTransforms with subprocess.stdio[0] and default encoding, noop transform', () => testGeneratorInputPipe(false, false, true, 'webTransform', [foobarString, 'utf8']));130test('Can use webTransforms with subprocess.stdin and default encoding, noop transform', () => testGeneratorInputPipe(true, false, true, 'webTransform', [foobarString, 'utf8']));131test('Can use webTransforms with subprocess.stdio[0] and encoding "utf16le", noop transform', () => testGeneratorInputPipe(false, false, true, 'webTransform', [foobarString, 'utf16le']));132test('Can use webTransforms with subprocess.stdin and encoding "utf16le", noop transform', () => testGeneratorInputPipe(true, false, true, 'webTransform', [foobarString, 'utf16le']));133test('Can use webTransforms with subprocess.stdio[0] and encoding "buffer", noop transform', () => testGeneratorInputPipe(false, false, true, 'webTransform', [foobarBuffer, 'buffer']));134test('Can use webTransforms with subprocess.stdin and encoding "buffer", noop transform', () => testGeneratorInputPipe(true, false, true, 'webTransform', [foobarBuffer, 'buffer']));135test('Can use webTransforms with subprocess.stdio[0] and encoding "hex", noop transform', () => testGeneratorInputPipe(false, false, true, 'webTransform', [foobarHex, 'hex']));136test('Can use webTransforms with subprocess.stdin and encoding "hex", noop transform', () => testGeneratorInputPipe(true, false, true, 'webTransform', [foobarHex, 'hex']));137test('Can use webTransforms with subprocess.stdio[0], objectMode, noop transform', () => testGeneratorInputPipe(false, true, true, 'webTransform', [foobarObject]));138test('Can use webTransforms with subprocess.stdin, objectMode, noop transform', () => testGeneratorInputPipe(true, true, true, 'webTransform', [foobarObject]));

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

line 139why, one step back
139

TweaksSindre Sorhusbefore adoption698a1b8

line 140why, one step back
140const testGeneratorStdioInputPipe = async (objectMode, addNoopTransform, type) => {

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 141–144why, one step back
141 const {input, generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);
142 const subprocess = execa('stdin-fd.js', ['3'], getStdio(3, [[], ...generators]));143 subprocess.stdio[3].write(Array.isArray(input) ? input[0] : input);144 const {stdout} = await subprocess;

TweaksSindre Sorhusbefore adoption698a1b8

line 145why, one step back
145 assert.equal(stdout, output);

Upgrade `tsd` and `c8` (#982)ehmickybefore adoption08eb743

lines 146–147why, one step back
146};
147

TweaksSindre Sorhusbefore adoption698a1b8

lines 148–159why, one step back
148test('Can use generators with subprocess.stdio[*] as input', () => testGeneratorStdioInputPipe(false, false, 'generator'));
149test('Can use generators with subprocess.stdio[*] as input, objectMode', () => testGeneratorStdioInputPipe(true, false, 'generator'));150test('Can use generators with subprocess.stdio[*] as input, noop transform', () => testGeneratorStdioInputPipe(false, true, 'generator'));151test('Can use generators with subprocess.stdio[*] as input, objectMode, noop transform', () => testGeneratorStdioInputPipe(true, true, 'generator'));152test('Can use duplexes with subprocess.stdio[*] as input', () => testGeneratorStdioInputPipe(false, false, 'duplex'));153test('Can use duplexes with subprocess.stdio[*] as input, objectMode', () => testGeneratorStdioInputPipe(true, false, 'duplex'));154test('Can use duplexes with subprocess.stdio[*] as input, noop transform', () => testGeneratorStdioInputPipe(false, true, 'duplex'));155test('Can use duplexes with subprocess.stdio[*] as input, objectMode, noop transform', () => testGeneratorStdioInputPipe(true, true, 'duplex'));156test('Can use webTransforms with subprocess.stdio[*] as input', () => testGeneratorStdioInputPipe(false, false, 'webTransform'));157test('Can use webTransforms with subprocess.stdio[*] as input, objectMode', () => testGeneratorStdioInputPipe(true, false, 'webTransform'));158test('Can use webTransforms with subprocess.stdio[*] as input, noop transform', () => testGeneratorStdioInputPipe(false, true, 'webTransform'));159test('Can use webTransforms with subprocess.stdio[*] as input, objectMode, noop transform', () => testGeneratorStdioInputPipe(true, true, 'webTransform'));