custom-command.js
This file
Path
test/verbose/custom-command.js
98 lines · 5.7 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–13why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {fullStdio} from '../helpers/stdio.js';5import {6 QUOTE,7 getNormalizedLine,8 testTimestamp,9 runVerboseSubprocess,10} from '../helpers/verbose.js';1112setFixtureDirectory();13TweaksSindre Sorhusbefore adoption698a1b8
line 14why, one step back14const testPrintCommandCustom = async (fdNumber, isSync) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 15–20why, one step back15 const {stderr} = await runVerboseSubprocess({16 optionsFixture: 'custom-print.js',17 isSync,18 type: 'command',19 fdNumber,20 });TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 22–23why, one step back22};23TweaksSindre Sorhusbefore adoption698a1b8
lines 24–33why, one step back24test('Prints command, verbose custom', () => testPrintCommandCustom(undefined, false));25test('Prints command, verbose custom, fd-specific stdout', () => testPrintCommandCustom('stdout', false));26test('Prints command, verbose custom, fd-specific stderr', () => testPrintCommandCustom('stderr', false));27test('Prints command, verbose custom, fd-specific fd3', () => testPrintCommandCustom('fd3', false));28test('Prints command, verbose custom, fd-specific ipc', () => testPrintCommandCustom('ipc', false));29test('Prints command, verbose custom, sync', () => testPrintCommandCustom(undefined, true));30test('Prints command, verbose custom, fd-specific stdout, sync', () => testPrintCommandCustom('stdout', true));31test('Prints command, verbose custom, fd-specific stderr, sync', () => testPrintCommandCustom('stderr', true));32test('Prints command, verbose custom, fd-specific fd3, sync', () => testPrintCommandCustom('fd3', true));33test('Prints command, verbose custom, fd-specific ipc, sync', () => testPrintCommandCustom('ipc', true));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 34why, one step back34TweaksSindre Sorhusbefore adoption698a1b8
line 35why, one step back35const testPrintCommandOrder = async (fdNumber, secondFdNumber, hasOutput) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 36–44why, one step back36 const {stderr} = await runVerboseSubprocess({37 optionsFixture: 'custom-print-multiple.js',38 type: 'command',39 fdNumber,40 secondFdNumber,41 ...fullStdio,42 });4344 if (hasOutput) {TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 46why, one step back46 } else {TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47 assert.equal(stderr, '');Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 48–50why, one step back48 }49};50TweaksSindre Sorhusbefore adoption698a1b8
lines 51–62why, one step back51test('Prints command, verbose custom, fd-specific stdout+stderr', () => testPrintCommandOrder('stdout', 'stderr', true));52test('Prints command, verbose custom, fd-specific stderr+stdout', () => testPrintCommandOrder('stderr', 'stdout', false));53test('Prints command, verbose custom, fd-specific stdout+fd3', () => testPrintCommandOrder('stdout', 'fd3', true));54test('Prints command, verbose custom, fd-specific fd3+stdout', () => testPrintCommandOrder('fd3', 'stdout', false));55test('Prints command, verbose custom, fd-specific stdout+ipc', () => testPrintCommandOrder('stdout', 'ipc', true));56test('Prints command, verbose custom, fd-specific ipc+stdout', () => testPrintCommandOrder('ipc', 'stdout', false));57test('Prints command, verbose custom, fd-specific stderr+fd3', () => testPrintCommandOrder('stderr', 'fd3', true));58test('Prints command, verbose custom, fd-specific fd3+stderr', () => testPrintCommandOrder('fd3', 'stderr', false));59test('Prints command, verbose custom, fd-specific stderr+ipc', () => testPrintCommandOrder('stderr', 'ipc', true));60test('Prints command, verbose custom, fd-specific ipc+stderr', () => testPrintCommandOrder('ipc', 'stderr', false));61test('Prints command, verbose custom, fd-specific fd3+ipc', () => testPrintCommandOrder('fd3', 'ipc', true));62test('Prints command, verbose custom, fd-specific ipc+fd3', () => testPrintCommandOrder('ipc', 'fd3', false));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 63why, one step back63TweaksSindre Sorhusbefore adoption698a1b8
line 64why, one step back64const testPrintCommandFunction = async (fdNumber, secondFdNumber) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 65–71why, one step back65 const {stderr} = await runVerboseSubprocess({66 optionsFixture: 'custom-print-function.js',67 type: 'command',68 fdNumber,69 secondFdNumber,70 ...fullStdio,71 });TweaksSindre Sorhusbefore adoption698a1b8
line 72why, one step back72 assert.equal(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 73–74why, one step back73};74TweaksSindre Sorhusbefore adoption698a1b8
lines 75–86why, one step back75test('Prints command, verbose custom, fd-specific stdout+stderr, single function', () => testPrintCommandFunction('stdout', 'stderr'));76test('Prints command, verbose custom, fd-specific stderr+stdout, single function', () => testPrintCommandFunction('stderr', 'stdout'));77test('Prints command, verbose custom, fd-specific stdout+fd3, single function', () => testPrintCommandFunction('stdout', 'fd3'));78test('Prints command, verbose custom, fd-specific fd3+stdout, single function', () => testPrintCommandFunction('fd3', 'stdout'));79test('Prints command, verbose custom, fd-specific stdout+ipc, single function', () => testPrintCommandFunction('stdout', 'ipc'));80test('Prints command, verbose custom, fd-specific ipc+stdout, single function', () => testPrintCommandFunction('ipc', 'stdout'));81test('Prints command, verbose custom, fd-specific stderr+fd3, single function', () => testPrintCommandFunction('stderr', 'fd3'));82test('Prints command, verbose custom, fd-specific fd3+stderr, single function', () => testPrintCommandFunction('fd3', 'stderr'));83test('Prints command, verbose custom, fd-specific stderr+ipc, single function', () => testPrintCommandFunction('stderr', 'ipc'));84test('Prints command, verbose custom, fd-specific ipc+stderr, single function', () => testPrintCommandFunction('ipc', 'stderr'));85test('Prints command, verbose custom, fd-specific fd3+ipc, single function', () => testPrintCommandFunction('fd3', 'ipc'));86test('Prints command, verbose custom, fd-specific ipc+fd3, single function', () => testPrintCommandFunction('ipc', 'fd3'));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 87why, one step back87TweaksSindre Sorhusbefore adoption698a1b8
line 88why, one step back88const testVerboseMessage = async isSync => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 89–93why, one step back89 const {stderr} = await runVerboseSubprocess({90 isSync,91 type: 'command',92 eventProperty: 'message',93 });TweaksSindre Sorhusbefore adoption698a1b8
line 94why, one step back94 assert.equal(getNormalizedLine(stderr), `noop-verbose.js ${QUOTE}. .${QUOTE}`);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 95–96why, one step back95};96TweaksSindre Sorhusbefore adoption698a1b8
lines 97–98why, one step back97test('"verbose" function receives verboseObject.message', () => testVerboseMessage(false));98test('"verbose" function receives verboseObject.message, sync', () => testVerboseMessage(true));