Skip to content
Myr

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 file

Take it

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import 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 back
3import {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();9

TweaksSindre Sorhusbefore adoption698a1b8

line 10why, one step back
10const testInputOverlapped = async fdNumber => {

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

line 11why, one step back
11 const {stdout} = await execa('stdin-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [foobarUint8Array, 'overlapped', 'pipe']));

TweaksSindre Sorhusbefore adoption698a1b8

line 12why, one step back
12 assert.equal(stdout, foobarString);

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

lines 13–14why, one step back
13};
14

TweaksSindre Sorhusbefore adoption698a1b8

lines 15–16why, one step back
15test('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 back
17

TweaksSindre Sorhusbefore adoption698a1b8

line 18why, one step back
18const testOutputOverlapped = async fdNumber => {

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

line 19why, one step back
19 const {stdio} = await execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, ['overlapped', 'pipe']));

TweaksSindre Sorhusbefore adoption698a1b8

line 20why, one step back
20 assert.equal(stdio[fdNumber], foobarString);

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

lines 21–22why, one step back
21};
22

TweaksSindre Sorhusbefore adoption698a1b8

lines 23–25why, one step back
23test('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 back
26

TweaksSindre Sorhusbefore adoption698a1b8

line 27why, one step back
27const testFd3Undefined = async (stdioOption, options) => {

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

line 28why, one step back
28 const subprocess = execa('empty.js', {...getStdio(3, stdioOption), ...options});

TweaksSindre Sorhusbefore adoption698a1b8

lines 29–30why, one step back
29 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 back
31
32 const {stdio} = await subprocess;

TweaksSindre Sorhusbefore adoption698a1b8

lines 33–34why, one step back
33 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 back
35};
36

TweaksSindre Sorhusbefore adoption698a1b8

lines 37–48why, one step back
37test('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'}));