Skip to content
Myr

info.js

This file

Path

test/verbose/info.js

94 lines · 4.5 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–3why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';3import {assertThrows} from '../helpers/assert.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–6why, one step back
4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
5import {execa, execaSync} from '../../index.js';6import {foobarString} from '../helpers/input.js';

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

line 7why, one step back
7import {nestedSubprocess} from '../helpers/nested.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 8–14why, one step back
8import {
9 QUOTE,10 getCommandLine,11 getOutputLine,12 getNormalizedLines,13 testTimestamp,14} from '../helpers/verbose.js';

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

line 15why, one step back
15import {earlyErrorOptions, earlyErrorOptionsSync} from '../helpers/early-error.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 16–18why, one step back
16
17setFixtureDirectory();18

TweaksSindre Sorhusbefore adoption698a1b8

line 19why, one step back
19const testVerboseGeneral = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 20why, one step back
20 const {all} = await execaMethod('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 21why, one step back
21 assert.deepEqual(getNormalizedLines(all), [

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 22–30why, one step back
22 `${testTimestamp} [0] $ node -e ${QUOTE}console.error(1)${QUOTE}`,
23 '1',24 `${testTimestamp} [0] √ (done in 0ms)`,25 `${testTimestamp} [1] $ node -e ${QUOTE}process.exit(2)${QUOTE}`,26 `${testTimestamp} [1] ‼ Command failed with exit code 2: node -e ${QUOTE}process.exit(2)${QUOTE}`,27 `${testTimestamp} [1] ‼ (done in 0ms)`,28 ]);29};30

TweaksSindre Sorhusbefore adoption698a1b8

lines 31–32why, one step back
31test('Prints command, NODE_DEBUG=execa + "inherit"', () => testVerboseGeneral(execa));
32test('Prints command, NODE_DEBUG=execa + "inherit", sync', () => testVerboseGeneral(execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 33why, one step back
33

TweaksSindre Sorhusbefore adoption698a1b8

line 34why, one step back
34test('NODE_DEBUG=execa changes verbose default value to "full"', async () => {

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

line 35why, one step back
35 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {}, {env: {NODE_DEBUG: 'execa'}});

TweaksSindre Sorhusbefore adoption698a1b8

lines 36–37why, one step back
36 assert.equal(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);
37 assert.equal(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 38–39why, one step back
38});
39

TweaksSindre Sorhusbefore adoption698a1b8

line 40why, one step back
40const testDebugEnvPriority = async isSync => {

Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f

line 41why, one step back
41 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', isSync}, {env: {NODE_DEBUG: 'execa'}});

TweaksSindre Sorhusbefore adoption698a1b8

lines 42–43why, one step back
42 assert.equal(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);
43 assert.equal(getOutputLine(stderr), undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 46–47why, one step back
46test('NODE_DEBUG=execa has lower priority', () => testDebugEnvPriority(false));
47test('NODE_DEBUG=execa has lower priority, sync', () => testDebugEnvPriority(true));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 48–52why, one step back
48
49const invalidFalseMessage = 'renamed to "verbose: \'none\'"';50const invalidTrueMessage = 'renamed to "verbose: \'short\'"';51const invalidUnknownMessage = 'Allowed values are: \'none\', \'short\', \'full\'';52

TweaksSindre Sorhusbefore adoption698a1b8

lines 53–54why, one step back
53const testInvalidVerbose = (verbose, expectedMessage, execaMethod) => {
54 const {message} = assertThrows(() => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 55–56why, one step back
55 execaMethod('empty.js', {verbose});
56 });

TweaksSindre Sorhusbefore adoption698a1b8

line 57why, one step back
57 assert.ok(message.includes(expectedMessage));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 58–59why, one step back
58};
59

TweaksSindre Sorhusbefore adoption698a1b8

lines 60–65why, one step back
60test('Does not allow "verbose: false"', () => testInvalidVerbose(false, invalidFalseMessage, execa));
61test('Does not allow "verbose: false", sync', () => testInvalidVerbose(false, invalidFalseMessage, execaSync));62test('Does not allow "verbose: true"', () => testInvalidVerbose(true, invalidTrueMessage, execa));63test('Does not allow "verbose: true", sync', () => testInvalidVerbose(true, invalidTrueMessage, execaSync));64test('Does not allow "verbose: \'unknown\'"', () => testInvalidVerbose('unknown', invalidUnknownMessage, execa));65test('Does not allow "verbose: \'unknown\'", sync', () => testInvalidVerbose('unknown', invalidUnknownMessage, execaSync));

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

line 66why, one step back
66

TweaksSindre Sorhusbefore adoption698a1b8

line 67why, one step back
67const testValidationError = async isSync => {

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

line 68why, one step back
68 const {stderr, nestedResult} = await nestedSubprocess('empty.js', {verbose: 'full', isSync, timeout: []});

TweaksSindre Sorhusbefore adoption698a1b8

lines 69–70why, one step back
69 assert.deepEqual(getNormalizedLines(stderr), [`${testTimestamp} [0] $ empty.js`]);
70 assert.ok(nestedResult instanceof Error);

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

lines 71–72why, one step back
71};
72

TweaksSindre Sorhusbefore adoption698a1b8

lines 73–74why, one step back
73test('Prints validation errors', () => testValidationError(false));
74test('Prints validation errors, sync', () => testValidationError(true));

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

line 75why, one step back
75

TweaksSindre Sorhusbefore adoption698a1b8

line 76why, one step back
76test('Prints early spawn errors', async () => {

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

line 77why, one step back
77 const {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptions, verbose: 'full'});

TweaksSindre Sorhusbefore adoption698a1b8

line 78why, one step back
78 assert.deepEqual(getNormalizedLines(stderr), [

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

lines 79–85why, one step back
79 `${testTimestamp} [0] $ empty.js`,
80 `${testTimestamp} [0] × Command failed with ERR_INVALID_ARG_TYPE: empty.js`,81 `${testTimestamp} [0] × The "options.detached" property must be of type boolean. Received type string ('true')`,82 `${testTimestamp} [0] × (done in 0ms)`,83 ]);84});85

TweaksSindre Sorhusbefore adoption698a1b8

line 86why, one step back
86test('Prints early spawn errors, sync', async () => {

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

line 87why, one step back
87 const {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptionsSync, verbose: 'full', isSync: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 88why, one step back
88 assert.deepEqual(getNormalizedLines(stderr), [

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

line 89why, one step back
89 `${testTimestamp} [0] $ empty.js`,

Update test coverage for Node.js 26 (#1242)Sindre Sorhusbefore adoption68986b7

lines 90–91why, one step back
90 `${testTimestamp} [0] × Command failed with ERR_INVALID_ARG_TYPE: empty.js`,
91 `${testTimestamp} [0] × The "options.windowsHide" property must be of type boolean. Received type string ('true')`,

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

lines 92–94why, one step back
92 `${testTimestamp} [0] × (done in 0ms)`,
93 ]);94});