verbose.js
This file
Path
test/helpers/verbose.js
105 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
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 2–5why, one step back2import {platform} from 'node:process';3import {stripVTControlCharacters} from 'node:util';4import {replaceSymbols} from 'figures';5import {foobarString} from './input.js';Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 6why, one step back6import {nestedSubprocess} from './nested.js';Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 7why, one step back7import {fullStdio} from './stdio.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 8–11why, one step back89const isWindows = platform === 'win32';10export const QUOTE = isWindows ? '"' : '\'';11TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12export const runErrorSubprocess = async (verbose, isSync = false, options = {}) => {Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
lines 13–14why, one step back13 const {expectExitCode = true, ...subprocessOptions} = options;14 const {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose, isSync, ...subprocessOptions});TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15 assert.ok(nestedResult instanceof Error);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 16why, one step back16 if (expectExitCode) {TweaksSindre Sorhusbefore adoption698a1b8
line 17why, one step back17 assert.ok(stderr.includes('exit code 2'));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 18–22why, one step back18 }1920 return stderr;21};22TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23export const runWarningSubprocess = async isSync => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 24why, one step back24 const {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose: 'short', reject: false, isSync});TweaksSindre Sorhusbefore adoption698a1b8
lines 25–26why, one step back25 assert.ok(nestedResult instanceof Error);26 assert.ok(stderr.includes('exit code 2'));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 27–29why, one step back27 return stderr;28};29TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30export const runEarlyErrorSubprocess = async isSync => {Refactor test helpers for the `verbose` option (#1128)ehmickybefore adoption18d320f
line 31why, one step back31 const {stderr, nestedResult} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', cwd: true, isSync});TweaksSindre Sorhusbefore adoption698a1b8
lines 32–33why, one step back32 assert.ok(nestedResult instanceof Error);33 assert.ok(nestedResult.message.startsWith('The "cwd" option must'));100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 34–36why, one step back34 return stderr;35};36Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 37–49why, one step back37export const runVerboseSubprocess = ({38 isSync = false,39 type,40 eventProperty,41 optionName,42 errorMessage,43 fdNumber,44 secondFdNumber,45 optionsFixture = 'custom-event.js',46 output = '. .',47 ...options48}) => nestedSubprocess('noop-verbose.js', [output], {49 ipc: !isSync,Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 50why, one step back50 ...getStdioForFd3Option(fdNumber, secondFdNumber),Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 51–62why, one step back51 optionsFixture,52 optionsInput: {53 type,54 eventProperty,55 optionName,56 errorMessage,57 fdNumber,58 secondFdNumber,59 },60 isSync,61 ...options,62});Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
lines 63–66why, one step back6364export const getStdioForFd3Option = (...values) => values.some(value => hasFd3Option(value)) ? fullStdio : {};6566const hasFd3Option = value => value === 'fd3' || (typeof value === 'object' && value !== null && Object.hasOwn(value, 'fd3'));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 67why, one step back67100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 68–73why, one step back68export const getCommandLine = stderr => getCommandLines(stderr)[0];69export const getCommandLines = stderr => getNormalizedLines(stderr).filter(line => isCommandLine(line));70const isCommandLine = line => line.includes(' $ ') || line.includes(' | ');71export const getOutputLine = stderr => getOutputLines(stderr)[0];72export const getOutputLines = stderr => getNormalizedLines(stderr).filter(line => isOutputLine(line));73const isOutputLine = line => line.includes('] ');Log IPC messages with `verbose: 'full'` (#1063)ehmickybefore adoption839c2fe
lines 74–76why, one step back74export const getIpcLine = stderr => getIpcLines(stderr)[0];75export const getIpcLines = stderr => getNormalizedLines(stderr).filter(line => isIpcLine(line));76const isIpcLine = line => line.includes(' * ');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 77–82why, one step back77export const getErrorLine = stderr => getErrorLines(stderr)[0];78export const getErrorLines = stderr => getNormalizedLines(stderr).filter(line => isErrorLine(line));79const isErrorLine = line => (line.includes(' × ') || line.includes(' ‼ ')) && !isCompletionLine(line);80export const getCompletionLine = stderr => getCompletionLines(stderr)[0];81export const getCompletionLines = stderr => getNormalizedLines(stderr).filter(line => isCompletionLine(line));82const isCompletionLine = line => line.includes('(done in');Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 83why, one step back83export const getNormalizedLine = stderr => getNormalizedLines(stderr)[0];100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 84–88why, one step back84export const getNormalizedLines = stderr => splitLines(normalizeStderr(stderr));85const splitLines = stderr => stderr.split('\n');8687const normalizeStderr = stderr => replaceSymbols(normalizeDuration(normalizeTimestamp(stripVTControlCharacters(stderr))), {useFallback: true});88export const testTimestamp = '[00:00:00.000]';Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 89why, one step back89const normalizeTimestamp = stderr => stderr.replaceAll(/^\[\d{2}:\d{2}:\d{2}.\d{3}\]/gm, () => testTimestamp);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 90–93why, one step back90const normalizeDuration = stderr => stderr.replaceAll(/\(done in [^)]+\)/g, '(done in 0ms)');9192export const getVerboseOption = (isVerbose, verbose = 'short') => ({verbose: isVerbose ? verbose : 'none'});93Add more tests for the `verbose` option (#1127)ehmickybefore adoption37e0024
lines 94–102why, one step back94export const stdoutNoneOption = {stdout: 'none'};95export const stdoutShortOption = {stdout: 'short'};96export const stdoutFullOption = {stdout: 'full'};97export const stderrNoneOption = {stderr: 'none'};98export const stderrShortOption = {stderr: 'short'};99export const stderrFullOption = {stderr: 'full'};100export const fd3NoneOption = {fd3: 'none'};101export const fd3ShortOption = {fd3: 'short'};102export const fd3FullOption = {fd3: 'full'};Log IPC messages with `verbose: 'full'` (#1063)ehmickybefore adoption839c2fe
lines 103–105why, one step back103export const ipcNoneOption = {ipc: 'none'};104export const ipcShortOption = {ipc: 'short'};105export const ipcFullOption = {ipc: 'full'};