output-enable.js
This file
Path
test/verbose/output-enable.js
165 lines · 9.8 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 3why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 4why, one step back4import {foobarString, foobarRed, foobarUtf16Uint8Array} from '../helpers/input.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 5why, one step back5import {fullStdio} from '../helpers/stdio.js';Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 6why, one step back6import {nestedSubprocess} from '../helpers/nested.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 7why, one step back7import {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 8why, one step back8 runErrorSubprocess,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 9–11why, one step back9 getOutputLine,10 getOutputLines,11 testTimestamp,Add more tests for the `verbose` option (#1127)ehmickybefore adoption37e0024
lines 12–17why, one step back12 stdoutNoneOption,13 stdoutShortOption,14 stdoutFullOption,15 stderrNoneOption,16 stderrShortOption,17 stderrFullOption,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 18–24why, one step back18 fd3NoneOption,19 fd3ShortOption,20 fd3FullOption,21} from '../helpers/verbose.js';2223setFixtureDirectory();24TweaksSindre Sorhusbefore adoption698a1b8
line 25why, one step back25const testPrintOutput = async (verbose, fdNumber, isSync) => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 26why, one step back26 const {stderr} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose, isSync});TweaksSindre Sorhusbefore adoption698a1b8
line 27why, one step back27 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 28–29why, one step back28};29TweaksSindre Sorhusbefore adoption698a1b8
lines 30–37why, one step back30test('Prints stdout, verbose "full"', () => testPrintOutput('full', 1, false));31test('Prints stderr, verbose "full"', () => testPrintOutput('full', 2, false));32test('Prints stdout, verbose "full", fd-specific', () => testPrintOutput(stdoutFullOption, 1, false));33test('Prints stderr, verbose "full", fd-specific', () => testPrintOutput(stderrFullOption, 2, false));34test('Prints stdout, verbose "full", sync', () => testPrintOutput('full', 1, true));35test('Prints stderr, verbose "full", sync', () => testPrintOutput('full', 2, true));36test('Prints stdout, verbose "full", fd-specific, sync', () => testPrintOutput(stdoutFullOption, 1, true));37test('Prints stderr, verbose "full", fd-specific, sync', () => testPrintOutput(stderrFullOption, 2, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 38why, one step back38Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 39why, one step back39// `subprocess.all` is created and piped into by Execa itself, which must not disable `verbose`TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40const testPrintOutputAll = async (verbose, isSync) => {Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
lines 41–43why, one step back41 const {stderr} = await nestedSubprocess('noop-both.js', [foobarString], {verbose, all: true, isSync});42 // An fd-specific `verbose` prints a single file descriptor, while `'full'` prints both43 const lineCount = verbose === 'full' ? 2 : 1;TweaksSindre Sorhusbefore adoption698a1b8
line 44why, one step back44 assert.deepEqual(getOutputLines(stderr), Array.from({length: lineCount}, () => `${testTimestamp} [0] ${foobarString}`));Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
lines 45–46why, one step back45};46TweaksSindre Sorhusbefore adoption698a1b8
lines 47–52why, one step back47test('Prints stdout and stderr, verbose "full", all: true', () => testPrintOutputAll('full', false));48test('Prints stdout, verbose "full", all: true, fd-specific', () => testPrintOutputAll(stdoutFullOption, false));49test('Prints stderr, verbose "full", all: true, fd-specific', () => testPrintOutputAll(stderrFullOption, false));50test('Prints stdout and stderr, verbose "full", all: true, sync', () => testPrintOutputAll('full', true));51test('Prints stdout, verbose "full", all: true, fd-specific, sync', () => testPrintOutputAll(stdoutFullOption, true));52test('Prints stderr, verbose "full", all: true, fd-specific, sync', () => testPrintOutputAll(stderrFullOption, true));Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 53why, one step back53TweaksSindre Sorhusbefore adoption698a1b8
line 54why, one step back54const testNoPrintOutput = async (verbose, fdNumber, isSync) => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 55why, one step back55 const {stderr} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose, ...fullStdio, isSync});TweaksSindre Sorhusbefore adoption698a1b8
line 56why, one step back56 assert.equal(getOutputLine(stderr), undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 57–58why, one step back57};58TweaksSindre Sorhusbefore adoption698a1b8
lines 59–98why, one step back59test('Does not print stdout, verbose default', () => testNoPrintOutput(undefined, 1, false));60test('Does not print stdout, verbose "none"', () => testNoPrintOutput('none', 1, false));61test('Does not print stdout, verbose "short"', () => testNoPrintOutput('short', 1, false));62test('Does not print stderr, verbose default', () => testNoPrintOutput(undefined, 2, false));63test('Does not print stderr, verbose "none"', () => testNoPrintOutput('none', 2, false));64test('Does not print stderr, verbose "short"', () => testNoPrintOutput('short', 2, false));65test('Does not print stdio[*], verbose default', () => testNoPrintOutput(undefined, 3, false));66test('Does not print stdio[*], verbose "none"', () => testNoPrintOutput('none', 3, false));67test('Does not print stdio[*], verbose "short"', () => testNoPrintOutput('short', 3, false));68test('Does not print stdio[*], verbose "full"', () => testNoPrintOutput('full', 3, false));69test('Does not print stdout, verbose default, fd-specific', () => testNoPrintOutput({}, 1, false));70test('Does not print stdout, verbose "none", fd-specific', () => testNoPrintOutput(stdoutNoneOption, 1, false));71test('Does not print stdout, verbose "short", fd-specific', () => testNoPrintOutput(stdoutShortOption, 1, false));72test('Does not print stderr, verbose default, fd-specific', () => testNoPrintOutput({}, 2, false));73test('Does not print stderr, verbose "none", fd-specific', () => testNoPrintOutput(stderrNoneOption, 2, false));74test('Does not print stderr, verbose "short", fd-specific', () => testNoPrintOutput(stderrShortOption, 2, false));75test('Does not print stdio[*], verbose default, fd-specific', () => testNoPrintOutput({}, 3, false));76test('Does not print stdio[*], verbose "none", fd-specific', () => testNoPrintOutput(fd3NoneOption, 3, false));77test('Does not print stdio[*], verbose "short", fd-specific', () => testNoPrintOutput(fd3ShortOption, 3, false));78test('Does not print stdio[*], verbose "full", fd-specific', () => testNoPrintOutput(fd3FullOption, 3, false));79test('Does not print stdout, verbose default, sync', () => testNoPrintOutput(undefined, 1, true));80test('Does not print stdout, verbose "none", sync', () => testNoPrintOutput('none', 1, true));81test('Does not print stdout, verbose "short", sync', () => testNoPrintOutput('short', 1, true));82test('Does not print stderr, verbose default, sync', () => testNoPrintOutput(undefined, 2, true));83test('Does not print stderr, verbose "none", sync', () => testNoPrintOutput('none', 2, true));84test('Does not print stderr, verbose "short", sync', () => testNoPrintOutput('short', 2, true));85test('Does not print stdio[*], verbose default, sync', () => testNoPrintOutput(undefined, 3, true));86test('Does not print stdio[*], verbose "none", sync', () => testNoPrintOutput('none', 3, true));87test('Does not print stdio[*], verbose "short", sync', () => testNoPrintOutput('short', 3, true));88test('Does not print stdio[*], verbose "full", sync', () => testNoPrintOutput('full', 3, true));89test('Does not print stdout, verbose default, fd-specific, sync', () => testNoPrintOutput({}, 1, true));90test('Does not print stdout, verbose "none", fd-specific, sync', () => testNoPrintOutput(stdoutNoneOption, 1, true));91test('Does not print stdout, verbose "short", fd-specific, sync', () => testNoPrintOutput(stdoutShortOption, 1, true));92test('Does not print stderr, verbose default, fd-specific, sync', () => testNoPrintOutput({}, 2, true));93test('Does not print stderr, verbose "none", fd-specific, sync', () => testNoPrintOutput(stderrNoneOption, 2, true));94test('Does not print stderr, verbose "short", fd-specific, sync', () => testNoPrintOutput(stderrShortOption, 2, true));95test('Does not print stdio[*], verbose default, fd-specific, sync', () => testNoPrintOutput({}, 3, true));96test('Does not print stdio[*], verbose "none", fd-specific, sync', () => testNoPrintOutput(fd3NoneOption, 3, true));97test('Does not print stdio[*], verbose "short", fd-specific, sync', () => testNoPrintOutput(fd3ShortOption, 3, true));98test('Does not print stdio[*], verbose "full", fd-specific, sync', () => testNoPrintOutput(fd3FullOption, 3, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 99why, one step back99TweaksSindre Sorhusbefore adoption698a1b8
lines 100–102why, one step back100const testPrintError = async isSync => {101 const stderr = await runErrorSubprocess('full', isSync);102 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 103–104why, one step back103};104TweaksSindre Sorhusbefore adoption698a1b8
lines 105–106why, one step back105test('Prints stdout after errors', () => testPrintError(false));106test('Prints stdout after errors, sync', () => testPrintError(true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 107why, one step back107TweaksSindre Sorhusbefore adoption698a1b8
line 108why, one step back108test('Does not quote spaces from stdout', async () => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 109why, one step back109 const {stderr} = await nestedSubprocess('noop.js', ['foo bar'], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 110why, one step back110 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] foo bar`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 111–112why, one step back111});112TweaksSindre Sorhusbefore adoption698a1b8
line 113why, one step back113test('Does not quote special punctuation from stdout', async () => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 114why, one step back114 const {stderr} = await nestedSubprocess('noop.js', ['%'], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 115why, one step back115 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] %`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 116–117why, one step back116});117TweaksSindre Sorhusbefore adoption698a1b8
line 118why, one step back118test('Does not escape internal characters from stdout', async () => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 119why, one step back119 const {stderr} = await nestedSubprocess('noop.js', ['ã'], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 120why, one step back120 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ã`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 121–122why, one step back121});122TweaksSindre Sorhusbefore adoption698a1b8
line 123why, one step back123test('Strips color sequences from stdout', async () => {Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 124why, one step back124 const {stderr} = await nestedSubprocess('noop.js', [foobarRed], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 125why, one step back125 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 126–127why, one step back126});127TweaksSindre Sorhusbefore adoption698a1b8
line 128why, one step back128test('Escapes control characters from stdout', async () => {Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 129why, one step back129 const {stderr} = await nestedSubprocess('noop.js', ['\u{1}'], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 130why, one step back130 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] \\u0001`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 131–132why, one step back131});132TweaksSindre Sorhusbefore adoption698a1b8
line 133why, one step back133test('Escapes tabs from stdout', async () => {Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b
line 134why, one step back134 const {stderr} = await nestedSubprocess('noop.js', [`${foobarString}\t${foobarString}`], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 135why, one step back135 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}\\t${foobarString}`);Fix `verbose` discarding IPC messages when its function throwsSindre Sorhusbefore adoptionb548d8b
lines 136–137why, one step back136});137TweaksSindre Sorhusbefore adoption698a1b8
line 138why, one step back138const testStdioSame = async fdNumber => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 139why, one step back139 const {nestedResult: {stdio}} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 140why, one step back140 assert.equal(stdio[fdNumber], foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 141–142why, one step back141};142TweaksSindre Sorhusbefore adoption698a1b8
lines 143–144why, one step back143test('Does not change subprocess.stdout', () => testStdioSame(1));144test('Does not change subprocess.stderr', () => testStdioSame(2));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 145why, one step back145TweaksSindre Sorhusbefore adoption698a1b8
line 146why, one step back146const testSingleNewline = async isSync => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 147why, one step back147 const {stderr} = await nestedSubprocess('noop-fd.js', ['1', '\n'], {verbose: 'full', isSync});TweaksSindre Sorhusbefore adoption698a1b8
line 148why, one step back148 assert.deepEqual(getOutputLines(stderr), [`${testTimestamp} [0] `]);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 149–150why, one step back149};150TweaksSindre Sorhusbefore adoption698a1b8
lines 151–152why, one step back151test('Prints stdout, single newline', () => testSingleNewline(false));152test('Prints stdout, single newline, sync', () => testSingleNewline(true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 153why, one step back153TweaksSindre Sorhusbefore adoption698a1b8
line 154why, one step back154const testUtf16 = async isSync => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
lines 155–160why, one step back155 const {stderr} = await nestedSubprocess('stdin.js', {156 verbose: 'full',157 input: foobarUtf16Uint8Array,158 encoding: 'utf16le',159 isSync,160 });TweaksSindre Sorhusbefore adoption698a1b8
line 161why, one step back161 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 162–163why, one step back162};163TweaksSindre Sorhusbefore adoption698a1b8
lines 164–165why, one step back164test('Can use encoding UTF16, verbose "full"', () => testUtf16(false));165test('Can use encoding UTF16, verbose "full", sync', () => testUtf16(true));