template.js
This file
Path
test/pipe/template.js
272 lines · 9.1 KiB · JavaScript
Last changed by
Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
History of this fileTake it
Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 1why, one step back1import {spawn} from 'node:child_process';Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 2why, one step back2import {pathToFileURL} from 'node:url';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 3why, one step back3import test from 'ava';Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 4why, one step back4import {$, execa} from '../../index.js';Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
line 5why, one step back5import {setFixtureDir, FIXTURES_DIR} from '../helpers/fixtures-dir.js';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 6–9why, one step back6import {foobarString} from '../helpers/input.js';78setFixtureDir();9Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 10why, one step back10test('$.pipe(subprocess)', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 11–14why, one step back11 const {stdout} = await $`noop.js ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`);12 t.is(stdout, foobarString);13});14Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 15why, one step back15test('execa.$.pipe(subprocess)', async t => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 16–19why, one step back16 const {stdout} = await execa('noop.js', [foobarString]).pipe($({stdin: 'pipe'})`stdin.js`);17 t.is(stdout, foobarString);18});19Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 20why, one step back20test('$.pipe.pipe(subprocess)', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 21–31why, one step back21 const {stdout} = await $`noop.js ${foobarString}`22 .pipe($({stdin: 'pipe'})`stdin.js`)23 .pipe($({stdin: 'pipe'})`stdin.js`);24 t.is(stdout, foobarString);25});2627test('$.pipe`command`', async t => {28 const {stdout} = await $`noop.js ${foobarString}`.pipe`stdin.js`;29 t.is(stdout, foobarString);30});31Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 32–36why, one step back32test('execa.$.pipe`command`', async t => {33 const {stdout} = await execa('noop.js', [foobarString]).pipe`stdin.js`;34 t.is(stdout, foobarString);35});36Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 37–43why, one step back37test('$.pipe.pipe`command`', async t => {38 const {stdout} = await $`noop.js ${foobarString}`39 .pipe`stdin.js`40 .pipe`stdin.js`;41 t.is(stdout, foobarString);42});43Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 44–82why, one step back44test('$.pipe("file")', async t => {45 const {stdout} = await $`noop.js ${foobarString}`.pipe('stdin.js');46 t.is(stdout, foobarString);47});4849test('execa.$.pipe("file")`', async t => {50 const {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js');51 t.is(stdout, foobarString);52});5354test('$.pipe.pipe("file")', async t => {55 const {stdout} = await $`noop.js ${foobarString}`56 .pipe`stdin.js`57 .pipe('stdin.js');58 t.is(stdout, foobarString);59});6061test('execa.$.pipe(fileUrl)`', async t => {62 const {stdout} = await execa('noop.js', [foobarString]).pipe(pathToFileURL(`${FIXTURES_DIR}/stdin.js`));63 t.is(stdout, foobarString);64});6566test('$.pipe("file", args, options)', async t => {67 const {stdout} = await $`noop.js ${foobarString}`.pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});68 t.is(stdout, foobarString);69});7071test('execa.$.pipe("file", args, options)`', async t => {72 const {stdout} = await execa('noop.js', [foobarString]).pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});73 t.is(stdout, foobarString);74});7576test('$.pipe.pipe("file", args, options)', async t => {77 const {stdout} = await $`noop.js ${foobarString}`78 .pipe`stdin.js`79 .pipe('node', ['stdin.js'], {cwd: FIXTURES_DIR});80 t.is(stdout, foobarString);81});82Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 83why, one step back83test('$.pipe(subprocess, pipeOptions)', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 84–87why, one step back84 const {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});85 t.is(stdout, foobarString);86});87Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 88why, one step back88test('execa.$.pipe(subprocess, pipeOptions)', async t => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 89–92why, one step back89 const {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});90 t.is(stdout, foobarString);91});92Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 93why, one step back93test('$.pipe.pipe(subprocess, pipeOptions)', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 94–104why, one step back94 const {stdout} = await $`noop-fd.js 2 ${foobarString}`95 .pipe($({stdin: 'pipe'})`noop-stdin-fd.js 2`, {from: 'stderr'})96 .pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});97 t.is(stdout, foobarString);98});99100test('$.pipe(pipeOptions)`command`', async t => {101 const {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe({from: 'stderr'})`stdin.js`;102 t.is(stdout, foobarString);103});104Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 105–109why, one step back105test('execa.$.pipe(pipeOptions)`command`', async t => {106 const {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe({from: 'stderr'})`stdin.js`;107 t.is(stdout, foobarString);108});109Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 110–116why, one step back110test('$.pipe.pipe(pipeOptions)`command`', async t => {111 const {stdout} = await $`noop-fd.js 2 ${foobarString}`112 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`113 .pipe({from: 'stderr'})`stdin.js`;114 t.is(stdout, foobarString);115});116Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 117–133why, one step back117test('$.pipe("file", pipeOptions)', async t => {118 const {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe('stdin.js', {from: 'stderr'});119 t.is(stdout, foobarString);120});121122test('execa.$.pipe("file", pipeOptions)', async t => {123 const {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe('stdin.js', {from: 'stderr'});124 t.is(stdout, foobarString);125});126127test('$.pipe.pipe("file", pipeOptions)', async t => {128 const {stdout} = await $`noop-fd.js 2 ${foobarString}`129 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`130 .pipe('stdin.js', {from: 'stderr'});131 t.is(stdout, foobarString);132});133Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 134–138why, one step back134test('$.pipe(options)`command`', async t => {135 const {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})`stdin.js`;136 t.is(stdout, `${foobarString}\n`);137});138Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 139–143why, one step back139test('execa.$.pipe(options)`command`', async t => {140 const {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})`stdin.js`;141 t.is(stdout, `${foobarString}\n`);142});143Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 144–150why, one step back144test('$.pipe.pipe(options)`command`', async t => {145 const {stdout} = await $`noop.js ${foobarString}`146 .pipe({})`stdin.js`147 .pipe({stripFinalNewline: false})`stdin.js`;148 t.is(stdout, `${foobarString}\n`);149});150Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 151–167why, one step back151test('$.pipe("file", options)', async t => {152 const {stdout} = await $`noop.js ${foobarString}`.pipe('stdin.js', {stripFinalNewline: false});153 t.is(stdout, `${foobarString}\n`);154});155156test('execa.$.pipe("file", options)', async t => {157 const {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js', {stripFinalNewline: false});158 t.is(stdout, `${foobarString}\n`);159});160161test('$.pipe.pipe("file", options)', async t => {162 const {stdout} = await $`noop.js ${foobarString}`163 .pipe({})`stdin.js`164 .pipe('stdin.js', {stripFinalNewline: false});165 t.is(stdout, `${foobarString}\n`);166});167Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 168why, one step back168test('$.pipe(pipeAndSubprocessOptions)`command`', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 169–172why, one step back169 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`.pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;170 t.is(stdout, `${foobarString}\n`);171});172Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 173why, one step back173test('execa.$.pipe(pipeAndSubprocessOptions)`command`', async t => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 174–177why, one step back174 const {stdout} = await execa('noop-fd.js', ['2', `${foobarString}\n`]).pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;175 t.is(stdout, `${foobarString}\n`);176});177Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 178why, one step back178test('$.pipe.pipe(pipeAndSubprocessOptions)`command`', async t => {Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 179–184why, one step back179 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`180 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`181 .pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;182 t.is(stdout, `${foobarString}\n`);183});184Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 185why, one step back185test('$.pipe("file", pipeAndSubprocessOptions)', async t => {Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 186–189why, one step back186 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`.pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});187 t.is(stdout, `${foobarString}\n`);188});189Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 190why, one step back190test('execa.$.pipe("file", pipeAndSubprocessOptions)', async t => {Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 191–194why, one step back191 const {stdout} = await execa('noop-fd.js', ['2', `${foobarString}\n`]).pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});192 t.is(stdout, `${foobarString}\n`);193});194Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 195why, one step back195test('$.pipe.pipe("file", pipeAndSubprocessOptions)', async t => {Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 196–201why, one step back196 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`197 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`198 .pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});199 t.is(stdout, `${foobarString}\n`);200});201Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 202–206why, one step back202test('$.pipe(options)(secondOptions)`command`', async t => {203 const {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;204 t.is(stdout, foobarString);205});206Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 207–211why, one step back207test('execa.$.pipe(options)(secondOptions)`command`', async t => {208 const {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;209 t.is(stdout, foobarString);210});211Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 212–218why, one step back212test('$.pipe.pipe(options)(secondOptions)`command`', async t => {213 const {stdout} = await $`noop.js ${foobarString}`214 .pipe({})({})`stdin.js`215 .pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;216 t.is(stdout, foobarString);217});218Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 219–228why, one step back219test('$.pipe`command` forces "stdin: pipe"', async t => {220 const {stdout} = await $`noop.js ${foobarString}`.pipe({stdin: 'ignore'})`stdin.js`;221 t.is(stdout, foobarString);222});223224test('execa.pipe("file") forces "stdin: "pipe"', async t => {225 const {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js', {stdin: 'ignore'});226 t.is(stdout, foobarString);227});228Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 229why, one step back229test('execa.pipe(subprocess) does not force "stdin: pipe"', async t => {Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 230–231why, one step back230 await t.throwsAsync(231 execa('noop.js', [foobarString]).pipe(execa('stdin.js', {stdin: 'ignore'})),Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
line 232why, one step back232 {message: /"stdin: 'ignore'" option is incompatible/},Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 233–235why, one step back233 );234});235Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 236why, one step back236test('$.pipe(options)(subprocess) fails', async t => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 237–240why, one step back237 await t.throwsAsync(238 $`empty.js`.pipe({stdout: 'pipe'})($`empty.js`),239 {message: /Please use \.pipe/},240 );Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 241–242why, one step back241});242Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 243why, one step back243test('execa.$.pipe(options)(subprocess) fails', async t => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 244–245why, one step back244 await t.throwsAsync(245 execa('empty.js').pipe({stdout: 'pipe'})($`empty.js`),Add `.pipe(command, args, options)` shortcut (#864)ehmickybefore adoption08f8e5d
lines 246–259why, one step back246 {message: /Please use \.pipe/},247 );248});249250test('$.pipe(options)("file") fails', async t => {251 await t.throwsAsync(252 $`empty.js`.pipe({stdout: 'pipe'})('empty.js'),253 {message: /Please use \.pipe/},254 );255});256257test('execa.$.pipe(options)("file") fails', async t => {258 await t.throwsAsync(259 execa('empty.js').pipe({stdout: 'pipe'})('empty.js'),Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 260–268why, one step back260 {message: /Please use \.pipe/},261 );262});263264const testInvalidPipe = async (t, ...args) => {265 await t.throwsAsync(266 $`empty.js`.pipe(...args),267 {message: /must be a template string/},268 );Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 269–270why, one step back269};270Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 271why, one step back271test('$.pipe(nonExecaSubprocess) fails', testInvalidPipe, spawn('node', ['--version']));Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 272why, one step back272test('$.pipe(false) fails', testInvalidPipe, false);