Skip to content
Myr

Add more tests for the `verbose: 'full'` option (#961)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent dce0393 · Browse files · 7 files+108 added−55 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+108 added−55 removed

  • tests:+108 added−55 removed

7 files+108 added−55 removed

deleted:test/fixtures/nested-big-array.js-8 removed
modified:test/fixtures/nested-input.js+8 added-3 removed
deleted:test/fixtures/nested-object.js-7 removed
modified:test/fixtures/nested-transform.js+24 added-3 removed
modified:test/fixtures/noop-132.js+3 added-5 removed
modified:test/stream/all.js+3 added-3 removed
modified:test/verbose/output.js+70 added-26 removed
5 unmodified lines
6import {red} from 'yoctocolors';7import {execa} from '../../index.js';8import {setFixtureDir} from '../helpers/fixtures-dir.js';9import {foobarString, foobarObject, foobarUppercase} from '../helpers/input.js';10import {simpleFull, noNewlinesChunks} from '../helpers/lines.js';11import {fullStdio} from '../helpers/stdio.js';12import {13 nestedExeca,14 nestedExecaAsync,
106 unmodified lines
121 const [[{stdio}]] = await Promise.all([once(subprocess, 'message'), subprocess]);122 t.is(stdio[fdNumber], foobarString);123};124124test('Does not change stdout', testStdioSame, 1);125test('Does not change stderr', testStdioSame, 2);125test('Does not change subprocess.stdout', testStdioSame, 1);126test('Does not change subprocess.stderr', testStdioSame, 2);127128const testLines = async (t, stripFinalNewline, execaMethod) => {129 const {stderr} = await execaMethod('noop-fd.js', ['1', simpleFull], {verbose: 'full', lines: true});130 t.deepEqual(getOutputLines(stderr), noNewlinesChunks.map(line => `${testTimestamp} [0] ${line}`));131};132133test('Prints stdout, "lines: true"', testLines, false, nestedExecaAsync);134test('Prints stdout, "lines: true", stripFinalNewline', testLines, true, nestedExecaAsync);135test('Prints stdout, "lines: true", sync', testLines, false, nestedExecaSync);136test('Prints stdout, "lines: true", stripFinalNewline, sync', testLines, true, nestedExecaSync);137127const testOnlyTransforms = async (t, type) => {128 const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', [foobarString], {verbose: 'full', type});138const testOnlyTransforms = async (t, type, isSync) => {139 const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', [foobarString], {verbose: 'full', type, isSync});140 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString.toUpperCase()}`);141};142132test('Prints stdout with only transforms', testOnlyTransforms, 'generator');133test('Prints stdout with only duplexes', testOnlyTransforms, 'duplex');143test('Prints stdout with only transforms', testOnlyTransforms, 'generator', false);144test('Prints stdout with only transforms, sync', testOnlyTransforms, 'generator', true);145test('Prints stdout with only duplexes', testOnlyTransforms, 'duplex', false);146135test('Prints stdout with object transforms', async t => {136 const {stderr} = await nestedExeca('nested-object.js', 'noop.js', {verbose: 'full'});147const testObjectMode = async (t, isSync) => {148 const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', {verbose: 'full', transformName: 'object', isSync});149 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${inspect(foobarObject)}`);138});150};151140test('Prints stdout with big object transforms', async t => {141 const {stderr} = await nestedExeca('nested-big-array.js', 'noop.js', {verbose: 'full'});152test('Prints stdout with object transforms', testObjectMode, false);153test('Prints stdout with object transforms, sync', testObjectMode, true);154155const testBigArray = async (t, isSync) => {156 const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', {verbose: 'full', transformName: 'bigArray', isSync});157 const lines = getOutputLines(stderr);158 t.is(lines[0], `${testTimestamp} [0] [`);159 t.true(lines[1].startsWith(`${testTimestamp} [0] 0, 1,`));160 t.is(lines.at(-1), `${testTimestamp} [0] ]`);146});161};162163test('Prints stdout with big object transforms', testBigArray, false);164test('Prints stdout with big object transforms, sync', testBigArray, true);165166const testObjectModeString = async (t, isSync) => {167 const {stderr} = await nestedExeca('nested-transform.js', 'noop.js', {verbose: 'full', transformName: 'stringObject', isSync});168 t.deepEqual(getOutputLines(stderr), noNewlinesChunks.map(line => `${testTimestamp} [0] ${line}`));169};170171test('Prints stdout with string transforms in objectMode', testObjectModeString, false);172test('Prints stdout with string transforms in objectMode, sync', testObjectModeString, true);173174test('Prints stdout one line at a time', async t => {175 const subprocess = nestedExecaAsync('noop-progressive.js', [foobarString], {verbose: 'full'});176177 for await (const chunk of on(subprocess.stderr, 'data')) {
42 unmodified lines
220221test('Prints stdout, single newline', testSingleNewline, nestedExecaAsync);222test('Prints stdout, single newline, sync', testSingleNewline, nestedExecaSync);223198test('Can use encoding UTF16, verbose "full"', async t => {199 const {stderr} = await nestedExeca('nested-input.js', 'stdin.js', {verbose: 'full', encoding: 'utf16le'});224const testUtf16 = async (t, isSync) => {225 const {stderr} = await nestedExeca('nested-input.js', 'stdin.js', [`${isSync}`], {verbose: 'full', encoding: 'utf16le'});226 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);201});227};228229test('Can use encoding UTF16, verbose "full"', testUtf16, false);230test('Can use encoding UTF16, verbose "full", sync', testUtf16, true);231203const testNoOutputOptions = async (t, options, fixtureName = 'nested.js') => {232const testNoOutputOptions = async (t, fixtureName, options = {}) => {233 const {stderr} = await nestedExeca(fixtureName, 'noop.js', [foobarString], {verbose: 'full', ...options});234 t.is(getOutputLine(stderr), undefined);235};236208test('Does not print stdout, encoding "buffer"', testNoOutputOptions, {encoding: 'buffer'});209test('Does not print stdout, encoding "hex"', testNoOutputOptions, {encoding: 'hex'});210test('Does not print stdout, encoding "base64"', testNoOutputOptions, {encoding: 'base64'});211test('Does not print stdout, stdout "ignore"', testNoOutputOptions, {stdout: 'ignore'});212test('Does not print stdout, stdout "inherit"', testNoOutputOptions, {stdout: 'inherit'});213test('Does not print stdout, stdout 1', testNoOutputOptions, {stdout: 1});214test('Does not print stdout, stdout Writable', testNoOutputOptions, {}, 'nested-writable.js');215test('Does not print stdout, stdout WritableStream', testNoOutputOptions, {}, 'nested-writable-web.js');216test('Does not print stdout, .pipe(stream)', testNoOutputOptions, {}, 'nested-pipe-stream.js');217test('Does not print stdout, .pipe(subprocess)', testNoOutputOptions, {}, 'nested-pipe-subprocess.js');237test('Does not print stdout, encoding "buffer"', testNoOutputOptions, 'nested.js', {encoding: 'buffer'});238test('Does not print stdout, encoding "hex"', testNoOutputOptions, 'nested.js', {encoding: 'hex'});239test('Does not print stdout, encoding "base64"', testNoOutputOptions, 'nested.js', {encoding: 'base64'});240test('Does not print stdout, stdout "ignore"', testNoOutputOptions, 'nested.js', {stdout: 'ignore'});241test('Does not print stdout, stdout "inherit"', testNoOutputOptions, 'nested.js', {stdout: 'inherit'});242test('Does not print stdout, stdout 1', testNoOutputOptions, 'nested.js', {stdout: 1});243test('Does not print stdout, stdout Writable', testNoOutputOptions, 'nested-writable.js');244test('Does not print stdout, stdout WritableStream', testNoOutputOptions, 'nested-writable-web.js');245test('Does not print stdout, .pipe(stream)', testNoOutputOptions, 'nested-pipe-stream.js');246test('Does not print stdout, .pipe(subprocess)', testNoOutputOptions, 'nested-pipe-subprocess.js');247test('Does not print stdout, encoding "buffer", sync', testNoOutputOptions, 'nested-sync.js', {encoding: 'buffer'});248test('Does not print stdout, encoding "hex", sync', testNoOutputOptions, 'nested-sync.js', {encoding: 'hex'});249test('Does not print stdout, encoding "base64", sync', testNoOutputOptions, 'nested-sync.js', {encoding: 'base64'});250test('Does not print stdout, stdout "ignore", sync', testNoOutputOptions, 'nested-sync.js', {stdout: 'ignore'});251test('Does not print stdout, stdout "inherit", sync', testNoOutputOptions, 'nested-sync.js', {stdout: 'inherit'});252test('Does not print stdout, stdout 1, sync', testNoOutputOptions, 'nested-sync.js', {stdout: 1});253254const testStdoutFile = async (t, fixtureName, getStdout) => {255 const file = tempfile();256 const {stderr} = await nestedExeca(fixtureName, 'noop.js', [foobarString], {verbose: 'full', stdout: getStdout(file)});
4 unmodified lines
261};262263test('Does not print stdout, stdout { file }', testStdoutFile, 'nested.js', file => ({file}));264test('Does not print stdout, stdout fileUrl', testStdoutFile, 'nested-file-url.js', file => file);265test('Does not print stdout, stdout { file }, sync', testStdoutFile, 'nested-sync.js', file => ({file}));266267const testPrintOutputOptions = async (t, options, execaMethod) => {268 const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: 'full', ...options});269 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);
29 unmodified lines
299};300301test('Prints stdout, .pipe(stream) + .unpipe()', testPrintOutputFixture, 'nested-pipe-stream.js', 'true');302test('Prints stdout, .pipe(subprocess) + .unpipe()', testPrintOutputFixture, 'nested-pipe-subprocess.js', 'true');303304const testInterleaved = async (t, expectedLines, execaMethod) => {305 const {stderr} = await execaMethod('noop-132.js', {verbose: 'full'});306 t.deepEqual(getOutputLines(stderr), expectedLines.map(line => `${testTimestamp} [0] ${line}`));307};308309test('Prints stdout + stderr interleaved', testInterleaved, [1, 2, 3], nestedExecaAsync);310test('Prints stdout + stderr not interleaved, sync', testInterleaved, [1, 3, 2], nestedExecaSync);