Skip to content
Myr

output-pipe.js

This file

Path

test/verbose/output-pipe.js

49 lines · 2.9 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–2why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 3–4why, one step back
3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
4import {foobarString} from '../helpers/input.js';

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

line 5why, one step back
5import {nestedSubprocess} from '../helpers/nested.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 6–14why, one step back
6import {
7 getOutputLine,8 getOutputLines,9 testTimestamp,10 getVerboseOption,11} from '../helpers/verbose.js';1213setFixtureDirectory();14

TweaksSindre Sorhusbefore adoption698a1b8

line 15why, one step back
15const testPipeOutput = async (parentFixture, sourceVerbose, destinationVerbose) => {

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

lines 16–21why, one step back
16 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {
17 parentFixture,18 sourceOptions: getVerboseOption(sourceVerbose, 'full'),19 destinationFile: 'stdin.js',20 destinationOptions: getVerboseOption(destinationVerbose, 'full'),21 });

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 22–24why, one step back
22
23 const lines = getOutputLines(stderr);24 const id = sourceVerbose && destinationVerbose ? 1 : 0;

TweaksSindre Sorhusbefore adoption698a1b8

line 25why, one step back
25 assert.deepEqual(lines, destinationVerbose

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 26–29why, one step back
26 ? [`${testTimestamp} [${id}] ${foobarString}`]
27 : []);28};29

TweaksSindre Sorhusbefore adoption698a1b8

lines 30–41why, one step back
30test('Prints stdout if both verbose with .pipe("file")', () => testPipeOutput('nested-pipe-file.js', true, true));
31test('Prints stdout if both verbose with .pipe`command`', () => testPipeOutput('nested-pipe-script.js', true, true));32test('Prints stdout if both verbose with .pipe(subprocess)', () => testPipeOutput('nested-pipe-subprocesses.js', true, true));33test('Prints stdout if only second verbose with .pipe("file")', () => testPipeOutput('nested-pipe-file.js', false, true));34test('Prints stdout if only second verbose with .pipe`command`', () => testPipeOutput('nested-pipe-script.js', false, true));35test('Prints stdout if only second verbose with .pipe(subprocess)', () => testPipeOutput('nested-pipe-subprocesses.js', false, true));36test('Does not print stdout if only first verbose with .pipe("file")', () => testPipeOutput('nested-pipe-file.js', true, false));37test('Does not print stdout if only first verbose with .pipe`command`', () => testPipeOutput('nested-pipe-script.js', true, false));38test('Does not print stdout if only first verbose with .pipe(subprocess)', () => testPipeOutput('nested-pipe-subprocesses.js', true, false));39test('Does not print stdout if neither verbose with .pipe("file")', () => testPipeOutput('nested-pipe-file.js', false, false));40test('Does not print stdout if neither verbose with .pipe`command`', () => testPipeOutput('nested-pipe-script.js', false, false));41test('Does not print stdout if neither verbose with .pipe(subprocess)', () => testPipeOutput('nested-pipe-subprocesses.js', false, false));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 42why, one step back
42

TweaksSindre Sorhusbefore adoption698a1b8

line 43why, one step back
43const testPrintOutputFixture = async parentFixture => {

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

line 44why, one step back
44 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {parentFixture, verbose: 'full', unpipe: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 45why, one step back
45 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 46–47why, one step back
46};
47

TweaksSindre Sorhusbefore adoption698a1b8

lines 48–49why, one step back
48test('Prints stdout, .pipe(stream) + .unpipe()', () => testPrintOutputFixture('nested-pipe-stream.js'));
49test('Prints stdout, .pipe(subprocess) + .unpipe()', () => testPrintOutputFixture('nested-pipe-subprocess.js'));