Skip to content
Myr

custom-start.js

This file

Path

test/verbose/custom-start.js

85 lines · 5.0 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import 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 back
3import {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();13

TweaksSindre Sorhusbefore adoption698a1b8

line 14why, one step back
14const testPrintCommandCustom = async (fdNumber, worker, isSync) => {

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 15–21why, one step back
15 const {stderr} = await runVerboseSubprocess({
16 optionsFixture: 'custom-print.js',17 worker,18 isSync,19 type: 'command',20 fdNumber,21 });

TweaksSindre Sorhusbefore adoption698a1b8

line 22why, one step back
22 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 23–24why, one step back
23};
24

TweaksSindre Sorhusbefore adoption698a1b8

lines 25–44why, one step back
25test('Prints command, verbose custom', () => testPrintCommandCustom(undefined, false, false));
26test('Prints command, verbose custom, fd-specific stdout', () => testPrintCommandCustom('stdout', false, false));27test('Prints command, verbose custom, fd-specific stderr', () => testPrintCommandCustom('stderr', false, false));28test('Prints command, verbose custom, fd-specific fd3', () => testPrintCommandCustom('fd3', false, false));29test('Prints command, verbose custom, fd-specific ipc', () => testPrintCommandCustom('ipc', false, false));30test('Prints command, verbose custom, sync', () => testPrintCommandCustom(undefined, false, true));31test('Prints command, verbose custom, fd-specific stdout, sync', () => testPrintCommandCustom('stdout', false, true));32test('Prints command, verbose custom, fd-specific stderr, sync', () => testPrintCommandCustom('stderr', false, true));33test('Prints command, verbose custom, fd-specific fd3, sync', () => testPrintCommandCustom('fd3', false, true));34test('Prints command, verbose custom, fd-specific ipc, sync', () => testPrintCommandCustom('ipc', false, true));35test('Prints command, verbose custom, worker', () => testPrintCommandCustom(undefined, true, false));36test('Prints command, verbose custom, fd-specific stdout, worker', () => testPrintCommandCustom('stdout', true, false));37test('Prints command, verbose custom, fd-specific stderr, worker', () => testPrintCommandCustom('stderr', true, false));38test('Prints command, verbose custom, fd-specific fd3, worker', () => testPrintCommandCustom('fd3', true, false));39test('Prints command, verbose custom, fd-specific ipc, worker', () => testPrintCommandCustom('ipc', true, false));40test('Prints command, verbose custom, worker, sync', () => testPrintCommandCustom(undefined, true, true));41test('Prints command, verbose custom, fd-specific stdout, worker, sync', () => testPrintCommandCustom('stdout', true, true));42test('Prints command, verbose custom, fd-specific stderr, worker, sync', () => testPrintCommandCustom('stderr', true, true));43test('Prints command, verbose custom, fd-specific fd3, worker, sync', () => testPrintCommandCustom('fd3', true, true));44test('Prints command, verbose custom, fd-specific ipc, worker, sync', () => testPrintCommandCustom('ipc', true, true));

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 45why, one step back
45

TweaksSindre Sorhusbefore adoption698a1b8

line 46why, one step back
46const testPrintCommandOrder = async (fdNumber, secondFdNumber, hasOutput) => {

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 47–55why, one step back
47 const {stderr} = await runVerboseSubprocess({
48 optionsFixture: 'custom-print-multiple.js',49 type: 'command',50 fdNumber,51 secondFdNumber,52 ...fullStdio,53 });5455 if (hasOutput) {

TweaksSindre Sorhusbefore adoption698a1b8

line 56why, one step back
56 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 57why, one step back
57 } else {

TweaksSindre Sorhusbefore adoption698a1b8

line 58why, one step back
58 assert.equal(stderr, '');

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 59–61why, one step back
59 }
60};61

TweaksSindre Sorhusbefore adoption698a1b8

lines 62–73why, one step back
62test('Prints command, verbose custom, fd-specific stdout+stderr', () => testPrintCommandOrder('stdout', 'stderr', true));
63test('Prints command, verbose custom, fd-specific stderr+stdout', () => testPrintCommandOrder('stderr', 'stdout', false));64test('Prints command, verbose custom, fd-specific stdout+fd3', () => testPrintCommandOrder('stdout', 'fd3', true));65test('Prints command, verbose custom, fd-specific fd3+stdout', () => testPrintCommandOrder('fd3', 'stdout', false));66test('Prints command, verbose custom, fd-specific stdout+ipc', () => testPrintCommandOrder('stdout', 'ipc', true));67test('Prints command, verbose custom, fd-specific ipc+stdout', () => testPrintCommandOrder('ipc', 'stdout', false));68test('Prints command, verbose custom, fd-specific stderr+fd3', () => testPrintCommandOrder('stderr', 'fd3', true));69test('Prints command, verbose custom, fd-specific fd3+stderr', () => testPrintCommandOrder('fd3', 'stderr', false));70test('Prints command, verbose custom, fd-specific stderr+ipc', () => testPrintCommandOrder('stderr', 'ipc', true));71test('Prints command, verbose custom, fd-specific ipc+stderr', () => testPrintCommandOrder('ipc', 'stderr', false));72test('Prints command, verbose custom, fd-specific fd3+ipc', () => testPrintCommandOrder('fd3', 'ipc', true));73test('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 74why, one step back
74

TweaksSindre Sorhusbefore adoption698a1b8

line 75why, one step back
75const testVerboseMessage = async isSync => {

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 76–80why, one step back
76 const {stderr} = await runVerboseSubprocess({
77 isSync,78 type: 'command',79 eventProperty: 'message',80 });

TweaksSindre Sorhusbefore adoption698a1b8

line 81why, one step back
81 assert.equal(stderr, `noop-verbose.js ${QUOTE}. .${QUOTE}`);

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 82–83why, one step back
82};
83

TweaksSindre Sorhusbefore adoption698a1b8

lines 84–85why, one step back
84test('"verbose" function receives verboseObject.message', () => testVerboseMessage(false));
85test('"verbose" function receives verboseObject.message, sync', () => testVerboseMessage(true));