Skip to content
Myr

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 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–8why, one step back
3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
4import {fullStdio} from '../helpers/stdio.js';5import {getNormalizedLine, testTimestamp, runVerboseSubprocess} from '../helpers/verbose.js';67setFixtureDirectory();8

TweaksSindre Sorhusbefore adoption698a1b8

line 9why, one step back
9const testPrintCompletionCustom = async (fdNumber, isSync) => {

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

lines 10–15why, one step back
10 const {stderr} = await runVerboseSubprocess({
11 optionsFixture: 'custom-print.js',12 isSync,13 type: 'duration',14 fdNumber,15 });

TweaksSindre Sorhusbefore adoption698a1b8

line 16why, one step back
16 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 back
17};
18

TweaksSindre Sorhusbefore adoption698a1b8

lines 19–28why, one step back
19test('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 back
29

TweaksSindre Sorhusbefore adoption698a1b8

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

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

lines 31–39why, one step back
31 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 back
40 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 back
41 } else {

TweaksSindre Sorhusbefore adoption698a1b8

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

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

lines 43–45why, one step back
43 }
44};45

TweaksSindre Sorhusbefore adoption698a1b8

lines 46–57why, one step back
46test('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 back
58

TweaksSindre Sorhusbefore adoption698a1b8

line 59why, one step back
59const testPrintCompletionFunction = async (fdNumber, secondFdNumber) => {

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

lines 60–66why, one step back
60 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 back
67 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 back
68};
69

TweaksSindre Sorhusbefore adoption698a1b8

lines 70–81why, one step back
70test('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 back
82

TweaksSindre Sorhusbefore adoption698a1b8

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

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

lines 84–88why, one step back
84 const {stderr} = await runVerboseSubprocess({
85 isSync,86 type: 'duration',87 eventProperty: 'message',88 });

TweaksSindre Sorhusbefore adoption698a1b8

line 89why, one step back
89 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 back
90};
91

TweaksSindre Sorhusbefore adoption698a1b8

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