custom-complete.js
This file
Path
test/verbose/custom-complete.js
93 lines · 5.8 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 3–8why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {fullStdio} from '../helpers/stdio.js';5import {getNormalizedLine, testTimestamp, runVerboseSubprocess} from '../helpers/verbose.js';67setFixtureDirectory();8TweaksSindre Sorhusbefore adoption698a1b8
line 9why, one step back9const testPrintCompletionCustom = async (fdNumber, isSync) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 10–15why, one step back10 const {stderr} = await runVerboseSubprocess({11 optionsFixture: 'custom-print.js',12 isSync,13 type: 'duration',14 fdNumber,15 });TweaksSindre Sorhusbefore adoption698a1b8
line 16why, one step back16 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 17–18why, one step back17};18TweaksSindre Sorhusbefore adoption698a1b8
lines 19–28why, one step back19test('Prints completion, verbose custom', () => testPrintCompletionCustom(undefined, false));20test('Prints completion, verbose custom, fd-specific stdout', () => testPrintCompletionCustom('stdout', false));21test('Prints completion, verbose custom, fd-specific stderr', () => testPrintCompletionCustom('stderr', false));22test('Prints completion, verbose custom, fd-specific fd3', () => testPrintCompletionCustom('fd3', false));23test('Prints completion, verbose custom, fd-specific ipc', () => testPrintCompletionCustom('ipc', false));24test('Prints completion, verbose custom, sync', () => testPrintCompletionCustom(undefined, true));25test('Prints completion, verbose custom, fd-specific stdout, sync', () => testPrintCompletionCustom('stdout', true));26test('Prints completion, verbose custom, fd-specific stderr, sync', () => testPrintCompletionCustom('stderr', true));27test('Prints completion, verbose custom, fd-specific fd3, sync', () => testPrintCompletionCustom('fd3', true));28test('Prints completion, verbose custom, fd-specific ipc, sync', () => testPrintCompletionCustom('ipc', true));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 29why, one step back29TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30const testPrintCompletionOrder = async (fdNumber, secondFdNumber, hasOutput) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 31–39why, one step back31 const {stderr} = await runVerboseSubprocess({32 optionsFixture: 'custom-print-multiple.js',33 type: 'duration',34 fdNumber,35 secondFdNumber,36 ...fullStdio,37 });3839 if (hasOutput) {TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 41why, one step back41 } else {TweaksSindre Sorhusbefore adoption698a1b8
line 42why, one step back42 assert.equal(stderr, '');Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 43–45why, one step back43 }44};45TweaksSindre Sorhusbefore adoption698a1b8
lines 46–57why, one step back46test('Prints completion, verbose custom, fd-specific stdout+stderr', () => testPrintCompletionOrder('stdout', 'stderr', true));47test('Prints completion, verbose custom, fd-specific stderr+stdout', () => testPrintCompletionOrder('stderr', 'stdout', false));48test('Prints completion, verbose custom, fd-specific stdout+fd3', () => testPrintCompletionOrder('stdout', 'fd3', true));49test('Prints completion, verbose custom, fd-specific fd3+stdout', () => testPrintCompletionOrder('fd3', 'stdout', false));50test('Prints completion, verbose custom, fd-specific stdout+ipc', () => testPrintCompletionOrder('stdout', 'ipc', true));51test('Prints completion, verbose custom, fd-specific ipc+stdout', () => testPrintCompletionOrder('ipc', 'stdout', false));52test('Prints completion, verbose custom, fd-specific stderr+fd3', () => testPrintCompletionOrder('stderr', 'fd3', true));53test('Prints completion, verbose custom, fd-specific fd3+stderr', () => testPrintCompletionOrder('fd3', 'stderr', false));54test('Prints completion, verbose custom, fd-specific stderr+ipc', () => testPrintCompletionOrder('stderr', 'ipc', true));55test('Prints completion, verbose custom, fd-specific ipc+stderr', () => testPrintCompletionOrder('ipc', 'stderr', false));56test('Prints completion, verbose custom, fd-specific fd3+ipc', () => testPrintCompletionOrder('fd3', 'ipc', true));57test('Prints completion, verbose custom, fd-specific ipc+fd3', () => testPrintCompletionOrder('ipc', 'fd3', false));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 58why, one step back58TweaksSindre Sorhusbefore adoption698a1b8
line 59why, one step back59const testPrintCompletionFunction = async (fdNumber, secondFdNumber) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 60–66why, one step back60 const {stderr} = await runVerboseSubprocess({61 optionsFixture: 'custom-print-function.js',62 type: 'duration',63 fdNumber,64 secondFdNumber,65 ...fullStdio,66 });TweaksSindre Sorhusbefore adoption698a1b8
line 67why, one step back67 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 68–69why, one step back68};69TweaksSindre Sorhusbefore adoption698a1b8
lines 70–81why, one step back70test('Prints completion, verbose custom, fd-specific stdout+stderr, single function', () => testPrintCompletionFunction('stdout', 'stderr'));71test('Prints completion, verbose custom, fd-specific stderr+stdout, single function', () => testPrintCompletionFunction('stderr', 'stdout'));72test('Prints completion, verbose custom, fd-specific stdout+fd3, single function', () => testPrintCompletionFunction('stdout', 'fd3'));73test('Prints completion, verbose custom, fd-specific fd3+stdout, single function', () => testPrintCompletionFunction('fd3', 'stdout'));74test('Prints completion, verbose custom, fd-specific stdout+ipc, single function', () => testPrintCompletionFunction('stdout', 'ipc'));75test('Prints completion, verbose custom, fd-specific ipc+stdout, single function', () => testPrintCompletionFunction('ipc', 'stdout'));76test('Prints completion, verbose custom, fd-specific stderr+fd3, single function', () => testPrintCompletionFunction('stderr', 'fd3'));77test('Prints completion, verbose custom, fd-specific fd3+stderr, single function', () => testPrintCompletionFunction('fd3', 'stderr'));78test('Prints completion, verbose custom, fd-specific stderr+ipc, single function', () => testPrintCompletionFunction('stderr', 'ipc'));79test('Prints completion, verbose custom, fd-specific ipc+stderr, single function', () => testPrintCompletionFunction('ipc', 'stderr'));80test('Prints completion, verbose custom, fd-specific fd3+ipc, single function', () => testPrintCompletionFunction('fd3', 'ipc'));81test('Prints completion, verbose custom, fd-specific ipc+fd3, single function', () => testPrintCompletionFunction('ipc', 'fd3'));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 82why, one step back82TweaksSindre Sorhusbefore adoption698a1b8
line 83why, one step back83const testVerboseMessage = async isSync => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 84–88why, one step back84 const {stderr} = await runVerboseSubprocess({85 isSync,86 type: 'duration',87 eventProperty: 'message',88 });TweaksSindre Sorhusbefore adoption698a1b8
line 89why, one step back89 assert.equal(getNormalizedLine(stderr), '(done in 0ms)');Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 90–91why, one step back90};91TweaksSindre Sorhusbefore adoption698a1b8
lines 92–93why, one step back92test('"verbose" function receives verboseObject.message', () => testVerboseMessage(false));93test('"verbose" function receives verboseObject.message, sync', () => testVerboseMessage(true));