Skip to content
Myr

setup.js

This file

Path

test/pipe/setup.js

28 lines · 1.8 KiB · JavaScript

Last changed by

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

History of this file

Take it

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 1–3why, one step back
1import test from 'ava';
2import {execa} from '../../index.js';3import {setFixtureDir} from '../helpers/fixtures-dir.js';

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

lines 4–5why, one step back
4import {fullStdio, fullReadableStdio} from '../helpers/stdio.js';
5import {foobarString} from '../helpers/input.js';

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 6–8why, one step back
6
7setFixtureDir();8

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

lines 9–13why, one step back
9// eslint-disable-next-line max-params
10const pipeToSubprocess = async (t, readableFdNumber, writableFdNumber, from, to, readableOptions = {}, writableOptions = {}) => {11 const {stdout} = await execa('noop-fd.js', [`${readableFdNumber}`, foobarString], readableOptions)12 .pipe(execa('stdin-fd.js', [`${writableFdNumber}`], writableOptions), {from, to});13 t.is(stdout, foobarString);

Improve piping processes (#834)ehmickybefore adoption1a47ea2

lines 14–15why, one step back
14};
15

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

lines 16–17why, one step back
16test('pipe(...) can pipe', pipeToSubprocess, 1, 0);
17test('pipe(..., {from: "stdout"}) can pipe', pipeToSubprocess, 1, 0, 'stdout');

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

line 18why, one step back
18test('pipe(..., {from: "fd1"}) can pipe', pipeToSubprocess, 1, 0, 'fd1');

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

line 19why, one step back
19test('pipe(..., {from: "stderr"}) can pipe stderr', pipeToSubprocess, 2, 0, 'stderr');

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

lines 20–21why, one step back
20test('pipe(..., {from: "fd2"}) can pipe', pipeToSubprocess, 2, 0, 'fd2');
21test('pipe(..., {from: "fd3"}) can pipe', pipeToSubprocess, 3, 0, 'fd3', undefined, fullStdio);

Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2

lines 22–26why, one step back
22test('pipe(..., {from: "all"}) can pipe stdout', pipeToSubprocess, 1, 0, 'all', undefined, {all: true});
23test('pipe(..., {from: "all"}) can pipe stderr', pipeToSubprocess, 2, 0, 'all', undefined, {all: true});24test('pipe(..., {from: "all"}) can pipe stdout even with "stderr: ignore"', pipeToSubprocess, 1, 0, 'all', undefined, {all: true, stderr: 'ignore'});25test('pipe(..., {from: "all"}) can pipe stderr even with "stdout: ignore"', pipeToSubprocess, 2, 0, 'all', undefined, {all: true, stdout: 'ignore'});26test('pipe(..., {to: "stdin"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'stdin');

Rename `from|to: 3` to `from|to: 'fd3'` (#920)ehmickybefore adoption8dfdd91

lines 27–28why, one step back
27test('pipe(..., {to: "fd0"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'fd0');
28test('pipe(..., {to: "fd3"}) can pipe', pipeToSubprocess, 1, 3, undefined, 'fd3', {}, fullReadableStdio());