handle-normal.js
This file
Path
test/stdio/handle-normal.js
48 lines · 2.6 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 3–9why, one step back3import {execa} from '../../index.js';4import {getStdio} from '../helpers/stdio.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString, foobarUint8Array} from '../helpers/input.js';78setFixtureDirectory();9TweaksSindre Sorhusbefore adoption698a1b8
line 10why, one step back10const testInputOverlapped = async fdNumber => {Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 11why, one step back11 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [foobarUint8Array, 'overlapped', 'pipe']));TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12 assert.equal(stdout, foobarString);Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 13–14why, one step back13};14TweaksSindre Sorhusbefore adoption698a1b8
lines 15–16why, one step back15test('stdin can be ["overlapped", "pipe"]', () => testInputOverlapped(0));16test('stdio[*] input can be ["overlapped", "pipe"]', () => testInputOverlapped(3));Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 17why, one step back17TweaksSindre Sorhusbefore adoption698a1b8
line 18why, one step back18const testOutputOverlapped = async fdNumber => {Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 19why, one step back19 const {stdio} = await execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, ['overlapped', 'pipe']));TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20 assert.equal(stdio[fdNumber], foobarString);Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 21–22why, one step back21};22TweaksSindre Sorhusbefore adoption698a1b8
lines 23–25why, one step back23test('stdout can be ["overlapped", "pipe"]', () => testOutputOverlapped(1));24test('stderr can be ["overlapped", "pipe"]', () => testOutputOverlapped(2));25test('stdio[*] output can be ["overlapped", "pipe"]', () => testOutputOverlapped(3));Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 26why, one step back26TweaksSindre Sorhusbefore adoption698a1b8
line 27why, one step back27const testFd3Undefined = async (stdioOption, options) => {Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 28why, one step back28 const subprocess = execa('empty.js', {...getStdio(3, stdioOption), ...options});TweaksSindre Sorhusbefore adoption698a1b8
lines 29–30why, one step back29 assert.equal(subprocess.stdio.length, 4);30 assert.equal(subprocess.stdio[3], null);Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 31–32why, one step back3132 const {stdio} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 33–34why, one step back33 assert.equal(stdio.length, 4);34 assert.equal(stdio[3], undefined);Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 35–36why, one step back35};36TweaksSindre Sorhusbefore adoption698a1b8
lines 37–48why, one step back37test('stdio[*] undefined means "ignore"', () => testFd3Undefined(undefined, {}));38test('stdio[*] null means "ignore"', () => testFd3Undefined(null, {}));39test('stdio[*] [undefined] means "ignore"', () => testFd3Undefined([undefined], {}));40test('stdio[*] [null] means "ignore"', () => testFd3Undefined([null], {}));41test('stdio[*] undefined means "ignore", "lines: true"', () => testFd3Undefined(undefined, {lines: true}));42test('stdio[*] null means "ignore", "lines: true"', () => testFd3Undefined(null, {lines: true}));43test('stdio[*] [undefined] means "ignore", "lines: true"', () => testFd3Undefined([undefined], {lines: true}));44test('stdio[*] [null] means "ignore", "lines: true"', () => testFd3Undefined([null], {lines: true}));45test('stdio[*] undefined means "ignore", "encoding: hex"', () => testFd3Undefined(undefined, {encoding: 'hex'}));46test('stdio[*] null means "ignore", "encoding: hex"', () => testFd3Undefined(null, {encoding: 'hex'}));47test('stdio[*] [undefined] means "ignore", "encoding: hex"', () => testFd3Undefined([undefined], {encoding: 'hex'}));48test('stdio[*] [null] means "ignore", "encoding: hex"', () => testFd3Undefined([null], {encoding: 'hex'}));