native-redirect.js
This file
Path
test/stdio/native-redirect.js
75 lines · 5.4 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–8why, one step back3import {execa} from '../../index.js';4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {foobarString} from '../helpers/input.js';67setFixtureDirectory();8TweaksSindre Sorhusbefore adoption698a1b8
line 9why, one step back9const testRedirect = async (stdioOption, fdNumber, isInput, isSync) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 10–14why, one step back10 const {fixtureName, ...options} = isInput11 ? {fixtureName: 'stdin-fd.js', input: foobarString}12 : {fixtureName: 'noop-fd.js'};13 const {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, `${isSync}`, fixtureName, foobarString], options);14 const resultFdNumber = isStderrDescriptor(stdioOption) ? 2 : 1;TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15 assert.equal(stdio[resultFdNumber], foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 16–21why, one step back16};1718const isStderrDescriptor = stdioOption => stdioOption === 219 || stdioOption === 'stderr'20 || (Array.isArray(stdioOption) && isStderrDescriptor(stdioOption[0]));21TweaksSindre Sorhusbefore adoption698a1b8
lines 22–75why, one step back22test('stdio[*] can be 0', () => testRedirect(0, 3, true, false));23test('stdio[*] can be [0]', () => testRedirect([0], 3, true, false));24test('stdio[*] can be [0, "pipe"]', () => testRedirect([0, 'pipe'], 3, true, false));25test('stdio[*] can be process.stdin', () => testRedirect('stdin', 3, true, false));26test('stdio[*] can be [process.stdin]', () => testRedirect(['stdin'], 3, true, false));27test('stdio[*] can be [process.stdin, "pipe"]', () => testRedirect(['stdin', 'pipe'], 3, true, false));28test('stdout can be 2', () => testRedirect(2, 1, false, false));29test('stdout can be [2]', () => testRedirect([2], 1, false, false));30test('stdout can be [2, "pipe"]', () => testRedirect([2, 'pipe'], 1, false, false));31test('stdout can be process.stderr', () => testRedirect('stderr', 1, false, false));32test('stdout can be [process.stderr]', () => testRedirect(['stderr'], 1, false, false));33test('stdout can be [process.stderr, "pipe"]', () => testRedirect(['stderr', 'pipe'], 1, false, false));34test('stderr can be 1', () => testRedirect(1, 2, false, false));35test('stderr can be [1]', () => testRedirect([1], 2, false, false));36test('stderr can be [1, "pipe"]', () => testRedirect([1, 'pipe'], 2, false, false));37test('stderr can be process.stdout', () => testRedirect('stdout', 2, false, false));38test('stderr can be [process.stdout]', () => testRedirect(['stdout'], 2, false, false));39test('stderr can be [process.stdout, "pipe"]', () => testRedirect(['stdout', 'pipe'], 2, false, false));40test('stdio[*] can be 1', () => testRedirect(1, 3, false, false));41test('stdio[*] can be [1]', () => testRedirect([1], 3, false, false));42test('stdio[*] can be [1, "pipe"]', () => testRedirect([1, 'pipe'], 3, false, false));43test('stdio[*] can be 2', () => testRedirect(2, 3, false, false));44test('stdio[*] can be [2]', () => testRedirect([2], 3, false, false));45test('stdio[*] can be [2, "pipe"]', () => testRedirect([2, 'pipe'], 3, false, false));46test('stdio[*] can be process.stdout', () => testRedirect('stdout', 3, false, false));47test('stdio[*] can be [process.stdout]', () => testRedirect(['stdout'], 3, false, false));48test('stdio[*] can be [process.stdout, "pipe"]', () => testRedirect(['stdout', 'pipe'], 3, false, false));49test('stdio[*] can be process.stderr', () => testRedirect('stderr', 3, false, false));50test('stdio[*] can be [process.stderr]', () => testRedirect(['stderr'], 3, false, false));51test('stdio[*] can be [process.stderr, "pipe"]', () => testRedirect(['stderr', 'pipe'], 3, false, false));52test('stdout can be 2, sync', () => testRedirect(2, 1, false, true));53test('stdout can be [2], sync', () => testRedirect([2], 1, false, true));54test('stdout can be [2, "pipe"], sync', () => testRedirect([2, 'pipe'], 1, false, true));55test('stdout can be process.stderr, sync', () => testRedirect('stderr', 1, false, true));56test('stdout can be [process.stderr], sync', () => testRedirect(['stderr'], 1, false, true));57test('stdout can be [process.stderr, "pipe"], sync', () => testRedirect(['stderr', 'pipe'], 1, false, true));58test('stderr can be 1, sync', () => testRedirect(1, 2, false, true));59test('stderr can be [1], sync', () => testRedirect([1], 2, false, true));60test('stderr can be [1, "pipe"], sync', () => testRedirect([1, 'pipe'], 2, false, true));61test('stderr can be process.stdout, sync', () => testRedirect('stdout', 2, false, true));62test('stderr can be [process.stdout], sync', () => testRedirect(['stdout'], 2, false, true));63test('stderr can be [process.stdout, "pipe"], sync', () => testRedirect(['stdout', 'pipe'], 2, false, true));64test('stdio[*] can be 1, sync', () => testRedirect(1, 3, false, true));65test('stdio[*] can be [1], sync', () => testRedirect([1], 3, false, true));66test('stdio[*] can be [1, "pipe"], sync', () => testRedirect([1, 'pipe'], 3, false, true));67test('stdio[*] can be 2, sync', () => testRedirect(2, 3, false, true));68test('stdio[*] can be [2], sync', () => testRedirect([2], 3, false, true));69test('stdio[*] can be [2, "pipe"], sync', () => testRedirect([2, 'pipe'], 3, false, true));70test('stdio[*] can be process.stdout, sync', () => testRedirect('stdout', 3, false, true));71test('stdio[*] can be [process.stdout], sync', () => testRedirect(['stdout'], 3, false, true));72test('stdio[*] can be [process.stdout, "pipe"], sync', () => testRedirect(['stdout', 'pipe'], 3, false, true));73test('stdio[*] can be process.stderr, sync', () => testRedirect('stderr', 3, false, true));74test('stdio[*] can be [process.stderr], sync', () => testRedirect(['stderr'], 3, false, true));75test('stdio[*] can be [process.stderr, "pipe"], sync', () => testRedirect(['stderr', 'pipe'], 3, false, true));