complete.js
This file
Path
test/verbose/complete.js
131 lines · 8.2 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
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 2why, one step back2import {stripVTControlCharacters} from 'node:util';TweaksSindre Sorhusbefore adoption698a1b8
line 3why, one step back3import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 4–5why, one step back4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {foobarString} from '../helpers/input.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
lines 8–10why, one step back8 runErrorSubprocess,9 runWarningSubprocess,10 runEarlyErrorSubprocess,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 11–14why, one step back11 getCompletionLine,12 getCompletionLines,13 testTimestamp,14 getVerboseOption,Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 15why, one step back15 getStdioForFd3Option,Add more tests for the `verbose` option (#1127)ehmickybefore adoption37e0024
lines 16–27why, one step back16 stdoutNoneOption,17 stdoutShortOption,18 stdoutFullOption,19 stderrNoneOption,20 stderrShortOption,21 stderrFullOption,22 fd3NoneOption,23 fd3ShortOption,24 fd3FullOption,25 ipcNoneOption,26 ipcShortOption,27 ipcFullOption,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 28–31why, one step back28} from '../helpers/verbose.js';2930setFixtureDirectory();31TweaksSindre Sorhusbefore adoption698a1b8
line 32why, one step back32const testPrintCompletion = async (verbose, isSync) => {Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 33why, one step back33 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, ...getStdioForFd3Option(verbose), isSync});TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34 assert.equal(getCompletionLine(stderr), `${testTimestamp} [0] √ (done in 0ms)`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 35–36why, one step back35};36TweaksSindre Sorhusbefore adoption698a1b8
lines 37–56why, one step back37test('Prints completion, verbose "short"', () => testPrintCompletion('short', false));38test('Prints completion, verbose "full"', () => testPrintCompletion('full', false));39test('Prints completion, verbose "short", fd-specific stdout', () => testPrintCompletion(stdoutShortOption, false));40test('Prints completion, verbose "full", fd-specific stdout', () => testPrintCompletion(stdoutFullOption, false));41test('Prints completion, verbose "short", fd-specific stderr', () => testPrintCompletion(stderrShortOption, false));42test('Prints completion, verbose "full", fd-specific stderr', () => testPrintCompletion(stderrFullOption, false));43test('Prints completion, verbose "short", fd-specific fd3', () => testPrintCompletion(fd3ShortOption, false));44test('Prints completion, verbose "full", fd-specific fd3', () => testPrintCompletion(fd3FullOption, false));45test('Prints completion, verbose "short", fd-specific ipc', () => testPrintCompletion(ipcShortOption, false));46test('Prints completion, verbose "full", fd-specific ipc', () => testPrintCompletion(ipcFullOption, false));47test('Prints completion, verbose "short", sync', () => testPrintCompletion('short', true));48test('Prints completion, verbose "full", sync', () => testPrintCompletion('full', true));49test('Prints completion, verbose "short", fd-specific stdout, sync', () => testPrintCompletion(stdoutShortOption, true));50test('Prints completion, verbose "full", fd-specific stdout, sync', () => testPrintCompletion(stdoutFullOption, true));51test('Prints completion, verbose "short", fd-specific stderr, sync', () => testPrintCompletion(stderrShortOption, true));52test('Prints completion, verbose "full", fd-specific stderr, sync', () => testPrintCompletion(stderrFullOption, true));53test('Prints completion, verbose "short", fd-specific fd3, sync', () => testPrintCompletion(fd3ShortOption, true));54test('Prints completion, verbose "full", fd-specific fd3, sync', () => testPrintCompletion(fd3FullOption, true));55test('Prints completion, verbose "short", fd-specific ipc, sync', () => testPrintCompletion(ipcShortOption, true));56test('Prints completion, verbose "full", fd-specific ipc, sync', () => testPrintCompletion(ipcFullOption, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 57why, one step back57TweaksSindre Sorhusbefore adoption698a1b8
line 58why, one step back58const testNoPrintCompletion = async (verbose, isSync) => {Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 59why, one step back59 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, ...getStdioForFd3Option(verbose), isSync});TweaksSindre Sorhusbefore adoption698a1b8
line 60why, one step back60 assert.equal(stderr, '');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 61–62why, one step back61};62TweaksSindre Sorhusbefore adoption698a1b8
lines 63–76why, one step back63test('Does not print completion, verbose "none"', () => testNoPrintCompletion('none', false));64test('Does not print completion, verbose default', () => testNoPrintCompletion(undefined, false));65test('Does not print completion, verbose "none", fd-specific stdout', () => testNoPrintCompletion(stdoutNoneOption, false));66test('Does not print completion, verbose "none", fd-specific stderr', () => testNoPrintCompletion(stderrNoneOption, false));67test('Does not print completion, verbose "none", fd-specific fd3', () => testNoPrintCompletion(fd3NoneOption, false));68test('Does not print completion, verbose "none", fd-specific ipc', () => testNoPrintCompletion(ipcNoneOption, false));69test('Does not print completion, verbose default, fd-specific', () => testNoPrintCompletion({}, false));70test('Does not print completion, verbose "none", sync', () => testNoPrintCompletion('none', true));71test('Does not print completion, verbose default, sync', () => testNoPrintCompletion(undefined, true));72test('Does not print completion, verbose "none", fd-specific stdout, sync', () => testNoPrintCompletion(stdoutNoneOption, true));73test('Does not print completion, verbose "none", fd-specific stderr, sync', () => testNoPrintCompletion(stderrNoneOption, true));74test('Does not print completion, verbose "none", fd-specific fd3, sync', () => testNoPrintCompletion(fd3NoneOption, true));75test('Does not print completion, verbose "none", fd-specific ipc, sync', () => testNoPrintCompletion(ipcNoneOption, true));76test('Does not print completion, verbose default, fd-specific, sync', () => testNoPrintCompletion({}, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 77why, one step back77TweaksSindre Sorhusbefore adoption698a1b8
lines 78–80why, one step back78const testPrintCompletionError = async isSync => {79 const stderr = await runErrorSubprocess('short', isSync);80 assert.equal(getCompletionLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 81–82why, one step back81};82TweaksSindre Sorhusbefore adoption698a1b8
lines 83–84why, one step back83test('Prints completion after errors', () => testPrintCompletionError(false));84test('Prints completion after errors, sync', () => testPrintCompletionError(true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 85why, one step back85TweaksSindre Sorhusbefore adoption698a1b8
lines 86–88why, one step back86const testPrintCompletionWarning = async isSync => {87 const stderr = await runWarningSubprocess(isSync);88 assert.equal(getCompletionLine(stderr), `${testTimestamp} [0] ‼ (done in 0ms)`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 89–90why, one step back89};90TweaksSindre Sorhusbefore adoption698a1b8
lines 91–92why, one step back91test('Prints completion after errors, "reject" false', () => testPrintCompletionWarning(false));92test('Prints completion after errors, "reject" false, sync', () => testPrintCompletionWarning(true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 93why, one step back93TweaksSindre Sorhusbefore adoption698a1b8
lines 94–96why, one step back94const testPrintCompletionEarly = async isSync => {95 const stderr = await runEarlyErrorSubprocess(isSync);96 assert.equal(getCompletionLine(stderr), undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 97–98why, one step back97};98TweaksSindre Sorhusbefore adoption698a1b8
lines 99–100why, one step back99test('Prints completion after early validation errors', () => testPrintCompletionEarly(false));100test('Prints completion after early validation errors, sync', () => testPrintCompletionEarly(true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 101why, one step back101TweaksSindre Sorhusbefore adoption698a1b8
line 102why, one step back102test('Prints duration', async () => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 103why, one step back103 const {stderr} = await nestedSubprocess('delay.js', ['1000'], {verbose: 'short'});TweaksSindre Sorhusbefore adoption698a1b8
line 104why, one step back104 assert.match(stripVTControlCharacters(stderr).split('\n').at(-1), /\(done in [\d.]+s\)/);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 105–106why, one step back105});106TweaksSindre Sorhusbefore adoption698a1b8
line 107why, one step back107const testPipeDuration = async (parentFixture, sourceVerbose, destinationVerbose) => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
lines 108–113why, one step back108 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {109 parentFixture,110 sourceOptions: getVerboseOption(sourceVerbose),111 destinationFile: 'stdin.js',112 destinationOptions: getVerboseOption(destinationVerbose),113 });100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 114–115why, one step back114115 const lines = getCompletionLines(stderr);TweaksSindre Sorhusbefore adoption698a1b8
lines 116–117why, one step back116 assert.equal(lines.includes(`${testTimestamp} [0] √ (done in 0ms)`), sourceVerbose || destinationVerbose);117 assert.equal(lines.includes(`${testTimestamp} [1] √ (done in 0ms)`), sourceVerbose && destinationVerbose);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 118–119why, one step back118};119TweaksSindre Sorhusbefore adoption698a1b8
lines 120–131why, one step back120test('Prints both durations piped with .pipe("file")', () => testPipeDuration('nested-pipe-file.js', true, true));121test('Prints both durations piped with .pipe`command`', () => testPipeDuration('nested-pipe-script.js', true, true));122test('Prints both durations piped with .pipe(subprocess)', () => testPipeDuration('nested-pipe-subprocesses.js', true, true));123test('Prints first duration piped with .pipe("file")', () => testPipeDuration('nested-pipe-file.js', true, false));124test('Prints first duration piped with .pipe`command`', () => testPipeDuration('nested-pipe-script.js', true, false));125test('Prints first duration piped with .pipe(subprocess)', () => testPipeDuration('nested-pipe-subprocesses.js', true, false));126test('Prints second duration piped with .pipe("file")', () => testPipeDuration('nested-pipe-file.js', false, true));127test('Prints second duration piped with .pipe`command`', () => testPipeDuration('nested-pipe-script.js', false, true));128test('Prints second duration piped with .pipe(subprocess)', () => testPipeDuration('nested-pipe-subprocesses.js', false, true));129test('Prints neither durations piped with .pipe("file")', () => testPipeDuration('nested-pipe-file.js', false, false));130test('Prints neither durations piped with .pipe`command`', () => testPipeDuration('nested-pipe-script.js', false, false));131test('Prints neither durations piped with .pipe(subprocess)', () => testPipeDuration('nested-pipe-subprocesses.js', false, false));