stdio-option.js
This file
Path
test/stdio/stdio-option.js
61 lines · 2.7 KiB · JavaScript
Last changed by
Fix wrong-typed options and arguments being silently ignored or coercedSindre Sorhusbefore adoptionb57d643
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 2why, one step back2import {inspect} from 'node:util';TweaksSindre Sorhusbefore adoption698a1b8
lines 3–4why, one step back3import test from 'node:test';4import {assertThrows} from '../helpers/assert.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 5–6why, one step back5import {normalizeStdioOption} from '../../lib/stdio/stdio-option.js';6TweaksSindre Sorhusbefore adoption698a1b8
line 7why, one step back7const stdioMacro = (input, expected) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 8why, one step back8 if (expected instanceof Error) {TweaksSindre Sorhusbefore adoption698a1b8
line 9why, one step back9 assertThrows(() => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 10–14why, one step back10 normalizeStdioOption(input);11 }, {message: expected.message});12 return;13 }14TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15 assert.deepEqual(normalizeStdioOption(input), expected);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 16–17why, one step back16};17TweaksSindre Sorhusbefore adoption698a1b8
lines 18–21why, one step back18const stdioCases = [19 [{stdio: 'inherit'}, ['inherit', 'inherit', 'inherit']],20 [{stdio: 'pipe'}, ['pipe', 'pipe', 'pipe']],21 [{stdio: 'ignore'}, ['ignore', 'ignore', 'ignore']],100% test coverage (#1018)ehmickybefore adoption9f65b86
line 22why, one step back22TweaksSindre Sorhusbefore adoption698a1b8
lines 23–36why, one step back23 [{}, ['pipe', 'pipe', 'pipe']],24 [{stdio: []}, ['pipe', 'pipe', 'pipe']],25 [{stdio: [0]}, [0, 'pipe', 'pipe']],26 [{stdio: [0, 1]}, [0, 1, 'pipe']],27 [{stdio: [0, 1, 2]}, [0, 1, 2]],28 [{stdio: [0, 1, 2, 3]}, [0, 1, 2, 3]],29 [{stdio: [undefined, 1, 2]}, ['pipe', 1, 2]],30 [{stdio: [null, 1, 2]}, ['pipe', 1, 2]],31 [{stdio: [0, undefined, 2]}, [0, 'pipe', 2]],32 [{stdio: [0, null, 2]}, [0, 'pipe', 2]],33 [{stdio: [0, 1, undefined]}, [0, 1, 'pipe']],34 [{stdio: [0, 1, null]}, [0, 1, 'pipe']],35 [{stdio: [0, 1, 2, undefined]}, [0, 1, 2, 'ignore']],36 [{stdio: [0, 1, 2, null]}, [0, 1, 2, 'ignore']],100% test coverage (#1018)ehmickybefore adoption9f65b86
line 37why, one step back37TweaksSindre Sorhusbefore adoption698a1b8
lines 38–48why, one step back38 [{stdin: 'pipe'}, ['pipe', 'pipe', 'pipe']],39 [{stdout: 'ignore'}, ['pipe', 'ignore', 'pipe']],40 [{stderr: 'inherit'}, ['pipe', 'pipe', 'inherit']],41 [{stdin: 'pipe', stdout: 'ignore', stderr: 'inherit'}, ['pipe', 'ignore', 'inherit']],42 [{stdin: 'pipe', stdout: 'ignore'}, ['pipe', 'ignore', 'pipe']],43 [{stdin: 'pipe', stderr: 'inherit'}, ['pipe', 'pipe', 'inherit']],44 [{stdout: 'ignore', stderr: 'inherit'}, ['pipe', 'ignore', 'inherit']],45 [{stdin: 0, stdout: 1, stderr: 2}, [0, 1, 2]],46 [{stdin: 0, stdout: 1}, [0, 1, 'pipe']],47 [{stdin: 0, stderr: 2}, [0, 'pipe', 2]],48 [{stdout: 1, stderr: 2}, ['pipe', 1, 2]],100% test coverage (#1018)ehmickybefore adoption9f65b86
line 49why, one step back49TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50 [{stdio: {foo: 'bar'}}, new TypeError('Expected `stdio` to be of type `string` or `Array`, got `object`')],Fix wrong-typed options and arguments being silently ignored or coercedSindre Sorhusbefore adoptionb57d643
line 51why, one step back51 [{stdio: null}, new TypeError('Expected `stdio` to be of type `string` or `Array`, got `null`')],100% test coverage (#1018)ehmickybefore adoption9f65b86
line 52why, one step back52TweaksSindre Sorhusbefore adoption698a1b8
lines 53–57why, one step back53 [{stdin: 'inherit', stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')],54 [{stdin: 'inherit', stdio: ['pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')],55 [{stdin: 'inherit', stdio: [undefined, 'pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')],56 [{stdin: 0, stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')],57];100% test coverage (#1018)ehmickybefore adoption9f65b86
line 58why, one step back58TweaksSindre Sorhusbefore adoption698a1b8
lines 59–61why, one step back59for (const [input, expected] of stdioCases) {60 test(`execa() ${inspect(input)}`, () => stdioMacro(input, expected));61}