forward.js
This file
Path
test/stdio/forward.js
41 lines · 1.9 KiB · JavaScript
Last changed by
Fix `stdio: [..., undefined]` option (#948)ehmickybefore adoption96d2ef7
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–4why, one step back1import test from 'ava';2import {execa} from '../../index.js';3import {getStdio} from '../helpers/stdio.js';4import {setFixtureDir} from '../helpers/fixtures-dir.js';Fix `stdio: [..., undefined]` option (#948)ehmickybefore adoption96d2ef7
line 5why, one step back5import {foobarString, foobarUint8Array} from '../helpers/input.js';Split files (#837)ehmickybefore adoption672c2d7
lines 6–8why, one step back67setFixtureDir();8Fix `stdio: [..., undefined]` option (#948)ehmickybefore adoption96d2ef7
lines 9–11why, one step back9const testInputOverlapped = async (t, fdNumber) => {10 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [foobarUint8Array, 'overlapped', 'pipe']));11 t.is(stdout, foobarString);Split files (#837)ehmickybefore adoption672c2d7
lines 12–13why, one step back12};13Fix `stdio: [..., undefined]` option (#948)ehmickybefore adoption96d2ef7
lines 14–41why, one step back14test('stdin can be ["overlapped", "pipe"]', testInputOverlapped, 0);15test('stdio[*] input can be ["overlapped", "pipe"]', testInputOverlapped, 3);1617const testOutputOverlapped = async (t, fdNumber) => {18 const {stdio} = await execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, ['overlapped', 'pipe']));19 t.is(stdio[fdNumber], foobarString);20};2122test('stdout can be ["overlapped", "pipe"]', testOutputOverlapped, 1);23test('stderr can be ["overlapped", "pipe"]', testOutputOverlapped, 2);24test('stdio[*] output can be ["overlapped", "pipe"]', testOutputOverlapped, 3);2526const testFd3Undefined = async (t, stdioOption, options) => {27 const subprocess = execa('empty.js', {...getStdio(3, stdioOption), ...options});28 t.is(subprocess.stdio.length, 4);29 t.is(subprocess.stdio[3], null);3031 const {stdio} = await subprocess;32 t.is(stdio.length, 4);33 t.is(stdio[3], undefined);34};3536test('stdio[*] undefined means "ignore"', testFd3Undefined, undefined, {});37test('stdio[*] null means "ignore"', testFd3Undefined, null, {});38test('stdio[*] undefined means "ignore", "lines: true"', testFd3Undefined, undefined, {lines: true});39test('stdio[*] null means "ignore", "lines: true"', testFd3Undefined, null, {lines: true});40test('stdio[*] undefined means "ignore", "encoding: hex"', testFd3Undefined, undefined, {encoding: 'hex'});41test('stdio[*] null means "ignore", "encoding: hex"', testFd3Undefined, null, {encoding: 'hex'});