direction.js
This file
Path
test/stdio/direction.js
51 lines · 2.8 KiB · JavaScript
Last changed by
Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–6why, one step back1import {readFile, writeFile, rm} from 'node:fs/promises';2import process from 'node:process';3import test from 'ava';4import tempfile from 'tempfile';5import {execa, execaSync} from '../../index.js';6import {getStdio} from '../helpers/stdio.js';Upgrade xo (#980)ehmickybefore adoptionccfa412
line 7why, one step back7import {setFixtureDirectory} from '../helpers/fixtures-directory.js';Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
line 8why, one step back8import {foobarString} from '../helpers/input.js';Split files (#837)ehmickybefore adoption672c2d7
line 9why, one step back9Upgrade xo (#980)ehmickybefore adoptionccfa412
line 10why, one step back10setFixtureDirectory();Split files (#837)ehmickybefore adoption672c2d7
lines 11–30why, one step back1112const testInputOutput = (t, stdioOption, execaMethod) => {13 t.throws(() => {14 execaMethod('empty.js', getStdio(3, [new ReadableStream(), stdioOption]));15 }, {message: /readable and writable/});16};1718test('Cannot pass both readable and writable values to stdio[*] - WritableStream', testInputOutput, new WritableStream(), execa);19test('Cannot pass both readable and writable values to stdio[*] - 1', testInputOutput, 1, execa);20test('Cannot pass both readable and writable values to stdio[*] - 2', testInputOutput, 2, execa);21test('Cannot pass both readable and writable values to stdio[*] - process.stdout', testInputOutput, process.stdout, execa);22test('Cannot pass both readable and writable values to stdio[*] - process.stderr', testInputOutput, process.stderr, execa);23test('Cannot pass both readable and writable values to stdio[*] - WritableStream - sync', testInputOutput, new WritableStream(), execaSync);24test('Cannot pass both readable and writable values to stdio[*] - 1 - sync', testInputOutput, 1, execaSync);25test('Cannot pass both readable and writable values to stdio[*] - 2 - sync', testInputOutput, 2, execaSync);26test('Cannot pass both readable and writable values to stdio[*] - process.stdout - sync', testInputOutput, process.stdout, execaSync);27test('Cannot pass both readable and writable values to stdio[*] - process.stderr - sync', testInputOutput, process.stderr, execaSync);2829const testAmbiguousDirection = async (t, execaMethod) => {30 const [filePathOne, filePathTwo] = [tempfile(), tempfile()];Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
line 31why, one step back31 await execaMethod('noop-fd.js', ['3', foobarString], getStdio(3, [{file: filePathOne}, {file: filePathTwo}]));Split files (#837)ehmickybefore adoption672c2d7
lines 32–33why, one step back32 t.deepEqual(33 await Promise.all([readFile(filePathOne, 'utf8'), readFile(filePathTwo, 'utf8')]),Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
line 34why, one step back34 [foobarString, foobarString],Split files (#837)ehmickybefore adoption672c2d7
lines 35–41why, one step back35 );36 await Promise.all([rm(filePathOne), rm(filePathTwo)]);37};3839test('stdio[*] default direction is output', testAmbiguousDirection, execa);40test('stdio[*] default direction is output - sync', testAmbiguousDirection, execaSync);41Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 42why, one step back42const testAmbiguousMultiple = async (t, fdNumber) => {Split files (#837)ehmickybefore adoption672c2d7
line 43why, one step back43 const filePath = tempfile();Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
line 44why, one step back44 await writeFile(filePath, foobarString);Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 45why, one step back45 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [{file: filePath}, ['foo', 'bar']]));Fix passing the same file or stream to both `stdout` and `stderr` (#1004)ehmickybefore adoptionea889c7
line 46why, one step back46 t.is(stdout, `${foobarString}${foobarString}`);Split files (#837)ehmickybefore adoption672c2d7
lines 47–51why, one step back47 await rm(filePath);48};4950test('stdin ambiguous direction is influenced by other values', testAmbiguousMultiple, 0);51test('stdio[*] ambiguous direction is influenced by other values', testAmbiguousMultiple, 3);