info.js
This file
Path
test/verbose/info.js
94 lines · 4.5 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–3why, one step back1import 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 back4import {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 back7import {nestedSubprocess} from '../helpers/nested.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 8–14why, one step back8import {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 back15import {earlyErrorOptions, earlyErrorOptionsSync} from '../helpers/early-error.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 16–18why, one step back1617setFixtureDirectory();18TweaksSindre Sorhusbefore adoption698a1b8
line 19why, one step back19const testVerboseGeneral = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 20why, one step back20 const {all} = await execaMethod('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21 assert.deepEqual(getNormalizedLines(all), [100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 22–30why, one step back22 `${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};30TweaksSindre Sorhusbefore adoption698a1b8
lines 31–32why, one step back31test('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 back33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34test('NODE_DEBUG=execa changes verbose default value to "full"', async () => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 35why, one step back35 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {}, {env: {NODE_DEBUG: 'execa'}});TweaksSindre Sorhusbefore adoption698a1b8
lines 36–37why, one step back36 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 back38});39TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40const testDebugEnvPriority = async isSync => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 41why, one step back41 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', isSync}, {env: {NODE_DEBUG: 'execa'}});TweaksSindre Sorhusbefore adoption698a1b8
lines 42–43why, one step back42 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 back44};45TweaksSindre Sorhusbefore adoption698a1b8
lines 46–47why, one step back46test('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 back4849const invalidFalseMessage = 'renamed to "verbose: \'none\'"';50const invalidTrueMessage = 'renamed to "verbose: \'short\'"';51const invalidUnknownMessage = 'Allowed values are: \'none\', \'short\', \'full\'';52TweaksSindre Sorhusbefore adoption698a1b8
lines 53–54why, one step back53const testInvalidVerbose = (verbose, expectedMessage, execaMethod) => {54 const {message} = assertThrows(() => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 55–56why, one step back55 execaMethod('empty.js', {verbose});56 });TweaksSindre Sorhusbefore adoption698a1b8
line 57why, one step back57 assert.ok(message.includes(expectedMessage));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 58–59why, one step back58};59TweaksSindre Sorhusbefore adoption698a1b8
lines 60–65why, one step back60test('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 back66TweaksSindre Sorhusbefore adoption698a1b8
line 67why, one step back67const testValidationError = async isSync => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 68why, one step back68 const {stderr, nestedResult} = await nestedSubprocess('empty.js', {verbose: 'full', isSync, timeout: []});TweaksSindre Sorhusbefore adoption698a1b8
lines 69–70why, one step back69 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 back71};72TweaksSindre Sorhusbefore adoption698a1b8
lines 73–74why, one step back73test('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 back75TweaksSindre Sorhusbefore adoption698a1b8
line 76why, one step back76test('Prints early spawn errors', async () => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 77why, one step back77 const {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptions, verbose: 'full'});TweaksSindre Sorhusbefore adoption698a1b8
line 78why, one step back78 assert.deepEqual(getNormalizedLines(stderr), [Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 79–85why, one step back79 `${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});85TweaksSindre Sorhusbefore adoption698a1b8
line 86why, one step back86test('Prints early spawn errors, sync', async () => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 87why, one step back87 const {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptionsSync, verbose: 'full', isSync: true});TweaksSindre Sorhusbefore adoption698a1b8
line 88why, one step back88 assert.deepEqual(getNormalizedLines(stderr), [Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 89why, one step back89 `${testTimestamp} [0] $ empty.js`,Update test coverage for Node.js 26 (#1242)Sindre Sorhusbefore adoption68986b7
lines 90–91why, one step back90 `${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 back92 `${testTimestamp} [0] × (done in 0ms)`,93 ]);94});