Skip to content
Myr

setup.js

This file

Path

test/pipe/setup.js

29 lines · 2.0 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 3–10why, one step back
3import {execa} from '../../index.js';
4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {fullStdio, fullReadableStdio} from '../helpers/stdio.js';6import {foobarString} from '../helpers/input.js';78setFixtureDirectory();910// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 11why, one step back
11const pipeToSubprocess = async (readableFdNumber, writableFdNumber, from, to, readableOptions = {}, writableOptions = {}) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 12–13why, one step back
12 const {stdout} = await execa('noop-fd.js', [`${readableFdNumber}`, foobarString], readableOptions)
13 .pipe(execa('stdin-fd.js', [`${writableFdNumber}`], writableOptions), {from, to});

TweaksSindre Sorhusbefore adoption698a1b8

line 14why, one step back
14 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 17–29why, one step back
17test('pipe(...) can pipe', () => pipeToSubprocess(1, 0));
18test('pipe(..., {from: "stdout"}) can pipe', () => pipeToSubprocess(1, 0, 'stdout'));19test('pipe(..., {from: "fd1"}) can pipe', () => pipeToSubprocess(1, 0, 'fd1'));20test('pipe(..., {from: "stderr"}) can pipe stderr', () => pipeToSubprocess(2, 0, 'stderr'));21test('pipe(..., {from: "fd2"}) can pipe', () => pipeToSubprocess(2, 0, 'fd2'));22test('pipe(..., {from: "fd3"}) can pipe', () => pipeToSubprocess(3, 0, 'fd3', undefined, fullStdio));23test('pipe(..., {from: "all"}) can pipe stdout', () => pipeToSubprocess(1, 0, 'all', undefined, {all: true}));24test('pipe(..., {from: "all"}) can pipe stderr', () => pipeToSubprocess(2, 0, 'all', undefined, {all: true}));25test('pipe(..., {from: "all"}) can pipe stdout even with "stderr: ignore"', () => pipeToSubprocess(1, 0, 'all', undefined, {all: true, stderr: 'ignore'}));26test('pipe(..., {from: "all"}) can pipe stderr even with "stdout: ignore"', () => pipeToSubprocess(2, 0, 'all', undefined, {all: true, stdout: 'ignore'}));27test('pipe(..., {to: "stdin"}) can pipe', () => pipeToSubprocess(1, 0, undefined, 'stdin'));28test('pipe(..., {to: "fd0"}) can pipe', () => pipeToSubprocess(1, 0, undefined, 'fd0'));29test('pipe(..., {to: "fd3"}) can pipe', () => pipeToSubprocess(1, 3, undefined, 'fd3', {}, fullReadableStdio()));