handle.js
This file
Path
test/stdio/handle.js
103 lines · 6.2 KiB · JavaScript
Last changed by
Do not allow `overlapped` with `execaSync()` (#949)ehmickybefore adoption7c2f575
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–7why, one step back1import test from 'ava';2import {execa, execaSync} from '../../index.js';3import {getStdio} from '../helpers/stdio.js';4import {setFixtureDir} from '../helpers/fixtures-dir.js';56setFixtureDir();7Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 8why, one step back8const testEmptyArray = (t, fdNumber, optionName, execaMethod) => {Split files (#837)ehmickybefore adoption672c2d7
line 9why, one step back9 t.throws(() => {Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 10why, one step back10 execaMethod('empty.js', getStdio(fdNumber, []));Split files (#837)ehmickybefore adoption672c2d7
lines 11–22why, one step back11 }, {message: `The \`${optionName}\` option must not be an empty array.`});12};1314test('Cannot pass an empty array to stdin', testEmptyArray, 0, 'stdin', execa);15test('Cannot pass an empty array to stdout', testEmptyArray, 1, 'stdout', execa);16test('Cannot pass an empty array to stderr', testEmptyArray, 2, 'stderr', execa);17test('Cannot pass an empty array to stdio[*]', testEmptyArray, 3, 'stdio[3]', execa);18test('Cannot pass an empty array to stdin - sync', testEmptyArray, 0, 'stdin', execaSync);19test('Cannot pass an empty array to stdout - sync', testEmptyArray, 1, 'stdout', execaSync);20test('Cannot pass an empty array to stderr - sync', testEmptyArray, 2, 'stderr', execaSync);21test('Cannot pass an empty array to stdio[*] - sync', testEmptyArray, 3, 'stdio[3]', execaSync);22Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 23why, one step back23const testNoPipeOption = async (t, stdioOption, fdNumber) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 24–26why, one step back24 const subprocess = execa('empty.js', getStdio(fdNumber, stdioOption));25 t.is(subprocess.stdio[fdNumber], null);26 await subprocess;Split files (#837)ehmickybefore adoption672c2d7
lines 27–65why, one step back27};2829test('stdin can be "ignore"', testNoPipeOption, 'ignore', 0);30test('stdin can be ["ignore"]', testNoPipeOption, ['ignore'], 0);31test('stdin can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 0);32test('stdin can be "ipc"', testNoPipeOption, 'ipc', 0);33test('stdin can be ["ipc"]', testNoPipeOption, ['ipc'], 0);34test('stdin can be "inherit"', testNoPipeOption, 'inherit', 0);35test('stdin can be ["inherit"]', testNoPipeOption, ['inherit'], 0);36test('stdin can be 0', testNoPipeOption, 0, 0);37test('stdin can be [0]', testNoPipeOption, [0], 0);38test('stdout can be "ignore"', testNoPipeOption, 'ignore', 1);39test('stdout can be ["ignore"]', testNoPipeOption, ['ignore'], 1);40test('stdout can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 1);41test('stdout can be "ipc"', testNoPipeOption, 'ipc', 1);42test('stdout can be ["ipc"]', testNoPipeOption, ['ipc'], 1);43test('stdout can be "inherit"', testNoPipeOption, 'inherit', 1);44test('stdout can be ["inherit"]', testNoPipeOption, ['inherit'], 1);45test('stdout can be 1', testNoPipeOption, 1, 1);46test('stdout can be [1]', testNoPipeOption, [1], 1);47test('stderr can be "ignore"', testNoPipeOption, 'ignore', 2);48test('stderr can be ["ignore"]', testNoPipeOption, ['ignore'], 2);49test('stderr can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 2);50test('stderr can be "ipc"', testNoPipeOption, 'ipc', 2);51test('stderr can be ["ipc"]', testNoPipeOption, ['ipc'], 2);52test('stderr can be "inherit"', testNoPipeOption, 'inherit', 2);53test('stderr can be ["inherit"]', testNoPipeOption, ['inherit'], 2);54test('stderr can be 2', testNoPipeOption, 2, 2);55test('stderr can be [2]', testNoPipeOption, [2], 2);56test('stdio[*] can be "ignore"', testNoPipeOption, 'ignore', 3);57test('stdio[*] can be ["ignore"]', testNoPipeOption, ['ignore'], 3);58test('stdio[*] can be ["ignore", "ignore"]', testNoPipeOption, ['ignore', 'ignore'], 3);59test('stdio[*] can be "ipc"', testNoPipeOption, 'ipc', 3);60test('stdio[*] can be ["ipc"]', testNoPipeOption, ['ipc'], 3);61test('stdio[*] can be "inherit"', testNoPipeOption, 'inherit', 3);62test('stdio[*] can be ["inherit"]', testNoPipeOption, ['inherit'], 3);63test('stdio[*] can be 3', testNoPipeOption, 3, 3);64test('stdio[*] can be [3]', testNoPipeOption, [3], 3);65Do not allow `overlapped` with `execaSync()` (#949)ehmickybefore adoption7c2f575
lines 66–70why, one step back66const testInvalidValueSync = (t, fdNumber, stdioOption) => {67 const {message} = t.throws(() => {68 execaSync('empty.js', getStdio(fdNumber, stdioOption));69 });70 t.true(message.includes(`cannot be "${stdioOption}" with synchronous methods`));Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1
lines 71–72why, one step back71};72Do not allow `overlapped` with `execaSync()` (#949)ehmickybefore adoption7c2f575
lines 73–80why, one step back73test('stdin cannot be "ipc", sync', testInvalidValueSync, 0, 'ipc');74test('stdout cannot be "ipc", sync', testInvalidValueSync, 1, 'ipc');75test('stderr cannot be "ipc", sync', testInvalidValueSync, 2, 'ipc');76test('stdio[*] cannot be "ipc", sync', testInvalidValueSync, 3, 'ipc');77test('stdin cannot be "overlapped", sync', testInvalidValueSync, 0, 'overlapped');78test('stdout cannot be "overlapped", sync', testInvalidValueSync, 1, 'overlapped');79test('stderr cannot be "overlapped", sync', testInvalidValueSync, 2, 'overlapped');80test('stdio[*] cannot be "overlapped", sync', testInvalidValueSync, 3, 'overlapped');Improve validation of `execaSync()` options (#940)ehmickybefore adoptionf6e1ac1
line 81why, one step back81Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 82why, one step back82const testInvalidArrayValue = (t, invalidStdio, fdNumber, execaMethod) => {Split files (#837)ehmickybefore adoption672c2d7
line 83why, one step back83 t.throws(() => {Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 84why, one step back84 execaMethod('empty.js', getStdio(fdNumber, ['pipe', invalidStdio]));Split files (#837)ehmickybefore adoption672c2d7
lines 85–103why, one step back85 }, {message: /must not include/});86};8788test('Cannot pass "ignore" and another value to stdin', testInvalidArrayValue, 'ignore', 0, execa);89test('Cannot pass "ignore" and another value to stdout', testInvalidArrayValue, 'ignore', 1, execa);90test('Cannot pass "ignore" and another value to stderr', testInvalidArrayValue, 'ignore', 2, execa);91test('Cannot pass "ignore" and another value to stdio[*]', testInvalidArrayValue, 'ignore', 3, execa);92test('Cannot pass "ignore" and another value to stdin - sync', testInvalidArrayValue, 'ignore', 0, execaSync);93test('Cannot pass "ignore" and another value to stdout - sync', testInvalidArrayValue, 'ignore', 1, execaSync);94test('Cannot pass "ignore" and another value to stderr - sync', testInvalidArrayValue, 'ignore', 2, execaSync);95test('Cannot pass "ignore" and another value to stdio[*] - sync', testInvalidArrayValue, 'ignore', 3, execaSync);96test('Cannot pass "ipc" and another value to stdin', testInvalidArrayValue, 'ipc', 0, execa);97test('Cannot pass "ipc" and another value to stdout', testInvalidArrayValue, 'ipc', 1, execa);98test('Cannot pass "ipc" and another value to stderr', testInvalidArrayValue, 'ipc', 2, execa);99test('Cannot pass "ipc" and another value to stdio[*]', testInvalidArrayValue, 'ipc', 3, execa);100test('Cannot pass "ipc" and another value to stdin - sync', testInvalidArrayValue, 'ipc', 0, execaSync);101test('Cannot pass "ipc" and another value to stdout - sync', testInvalidArrayValue, 'ipc', 1, execaSync);102test('Cannot pass "ipc" and another value to stderr - sync', testInvalidArrayValue, 'ipc', 2, execaSync);103test('Cannot pass "ipc" and another value to stdio[*] - sync', testInvalidArrayValue, 'ipc', 3, execaSync);