Skip to content
Myr

pipeline.js

This file

Path

test/io/pipeline.js

42 lines · 2.2 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–3why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';3import {assertRejects, assertLike} from '../helpers/assert.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–6why, one step back
4import {execa} from '../../index.js';
5import {getStdio, STANDARD_STREAMS} from '../helpers/stdio.js';6import {setFixtureDirectory} from '../helpers/fixtures-directory.js';

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

line 7why, one step back
7import {getEarlyErrorSubprocess, expectedEarlyError} from '../helpers/early-error.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 8–10why, one step back
8
9setFixtureDirectory();10

TweaksSindre Sorhusbefore adoption698a1b8

line 11why, one step back
11const testDestroyStandard = async fdNumber => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 12why, one step back
12 const subprocess = execa('forever.js', {...getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe']), timeout: 1});

TweaksSindre Sorhusbefore adoption698a1b8

lines 13–14why, one step back
13 await assertRejects(subprocess, {message: /timed out/});
14 assert.ok(!STANDARD_STREAMS[fdNumber].destroyed);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 15–16why, one step back
15};
16

TweaksSindre Sorhusbefore adoption698a1b8

lines 17–19why, one step back
17test('Does not destroy process.stdin on subprocess errors', () => testDestroyStandard(0));
18test('Does not destroy process.stdout on subprocess errors', () => testDestroyStandard(1));19test('Does not destroy process.stderr on subprocess errors', () => testDestroyStandard(2));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 20why, one step back
20

TweaksSindre Sorhusbefore adoption698a1b8

lines 21–24why, one step back
21const testDestroyStandardSpawn = async fdNumber => {
22 const error = await assertRejects(getEarlyErrorSubprocess(getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe'])));23 assertLike(error, expectedEarlyError);24 assert.ok(!STANDARD_STREAMS[fdNumber].destroyed);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 25–26why, one step back
25};
26

TweaksSindre Sorhusbefore adoption698a1b8

lines 27–29why, one step back
27test('Does not destroy process.stdin on subprocess early errors', () => testDestroyStandardSpawn(0));
28test('Does not destroy process.stdout on subprocess early errors', () => testDestroyStandardSpawn(1));29test('Does not destroy process.stderr on subprocess early errors', () => testDestroyStandardSpawn(2));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 30why, one step back
30

TweaksSindre Sorhusbefore adoption698a1b8

line 31why, one step back
31const testDestroyStandardStream = async fdNumber => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 32–35why, one step back
32 const subprocess = execa('forever.js', getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe']));
33 const cause = new Error('test');34 subprocess.stdio[fdNumber].destroy(cause);35 subprocess.kill();

TweaksSindre Sorhusbefore adoption698a1b8

lines 36–37why, one step back
36 assertLike(await assertRejects(subprocess), {cause});
37 assert.ok(!STANDARD_STREAMS[fdNumber].destroyed);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 38–39why, one step back
38};
39

TweaksSindre Sorhusbefore adoption698a1b8

lines 40–42why, one step back
40test('Does not destroy process.stdin on stream subprocess errors', () => testDestroyStandardStream(0));
41test('Does not destroy process.stdout on stream subprocess errors', () => testDestroyStandardStream(1));42test('Does not destroy process.stderr on stream subprocess errors', () => testDestroyStandardStream(2));