Skip to content

Commit 37e0024

Browse files
authored
Add more tests for the verbose option (#1127)
1 parent f9f1199 commit 37e0024

File tree

6 files changed

+156
-67
lines changed

6 files changed

+156
-67
lines changed

test/helpers/verbose.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,15 @@ const normalizeDuration = stderr => stderr.replaceAll(/\(done in [^)]+\)/g, '(do
6666

6767
export const getVerboseOption = (isVerbose, verbose = 'short') => ({verbose: isVerbose ? verbose : 'none'});
6868

69-
export const fdNoneOption = {stdout: 'none', stderr: 'none'};
70-
export const fdShortOption = {stdout: 'short', stderr: 'none'};
71-
export const fdFullOption = {stdout: 'full', stderr: 'none'};
72-
export const fdStdoutNoneOption = {stdout: 'none', stderr: 'full'};
73-
export const fdStderrNoneOption = {stdout: 'full', stderr: 'none'};
74-
export const fdStderrShortOption = {stdout: 'none', stderr: 'short'};
75-
export const fdStderrFullOption = {stdout: 'none', stderr: 'full'};
76-
export const fd3NoneOption = {stdout: 'full', fd3: 'none'};
77-
export const fd3ShortOption = {stdout: 'none', fd3: 'short'};
78-
export const fd3FullOption = {stdout: 'none', fd3: 'full'};
69+
export const stdoutNoneOption = {stdout: 'none'};
70+
export const stdoutShortOption = {stdout: 'short'};
71+
export const stdoutFullOption = {stdout: 'full'};
72+
export const stderrNoneOption = {stderr: 'none'};
73+
export const stderrShortOption = {stderr: 'short'};
74+
export const stderrFullOption = {stderr: 'full'};
75+
export const fd3NoneOption = {fd3: 'none'};
76+
export const fd3ShortOption = {fd3: 'short'};
77+
export const fd3FullOption = {fd3: 'full'};
7978
export const ipcNoneOption = {ipc: 'none'};
8079
export const ipcShortOption = {ipc: 'short'};
8180
export const ipcFullOption = {ipc: 'full'};

test/verbose/complete.js

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ import {
1515
getCompletionLines,
1616
testTimestamp,
1717
getVerboseOption,
18-
fdNoneOption,
19-
fdShortOption,
20-
fdFullOption,
18+
stdoutNoneOption,
19+
stdoutShortOption,
20+
stdoutFullOption,
21+
stderrNoneOption,
22+
stderrShortOption,
23+
stderrFullOption,
24+
fd3NoneOption,
25+
fd3ShortOption,
26+
fd3FullOption,
27+
ipcNoneOption,
28+
ipcShortOption,
29+
ipcFullOption,
2130
} from '../helpers/verbose.js';
2231

2332
setFixtureDirectory();
@@ -29,12 +38,24 @@ const testPrintCompletion = async (t, verbose, execaMethod) => {
2938

3039
test('Prints completion, verbose "short"', testPrintCompletion, 'short', parentExecaAsync);
3140
test('Prints completion, verbose "full"', testPrintCompletion, 'full', parentExecaAsync);
32-
test('Prints completion, verbose "short", fd-specific', testPrintCompletion, fdShortOption, parentExecaAsync);
33-
test('Prints completion, verbose "full", fd-specific', testPrintCompletion, fdFullOption, parentExecaAsync);
41+
test('Prints completion, verbose "short", fd-specific stdout', testPrintCompletion, stdoutShortOption, parentExecaAsync);
42+
test('Prints completion, verbose "full", fd-specific stdout', testPrintCompletion, stdoutFullOption, parentExecaAsync);
43+
test('Prints completion, verbose "short", fd-specific stderr', testPrintCompletion, stderrShortOption, parentExecaAsync);
44+
test('Prints completion, verbose "full", fd-specific stderr', testPrintCompletion, stderrFullOption, parentExecaAsync);
45+
test('Prints completion, verbose "short", fd-specific fd3', testPrintCompletion, fd3ShortOption, parentExecaAsync);
46+
test('Prints completion, verbose "full", fd-specific fd3', testPrintCompletion, fd3FullOption, parentExecaAsync);
47+
test('Prints completion, verbose "short", fd-specific ipc', testPrintCompletion, ipcShortOption, parentExecaAsync);
48+
test('Prints completion, verbose "full", fd-specific ipc', testPrintCompletion, ipcFullOption, parentExecaAsync);
3449
test('Prints completion, verbose "short", sync', testPrintCompletion, 'short', parentExecaSync);
3550
test('Prints completion, verbose "full", sync', testPrintCompletion, 'full', parentExecaSync);
36-
test('Prints completion, verbose "short", fd-specific, sync', testPrintCompletion, fdShortOption, parentExecaSync);
37-
test('Prints completion, verbose "full", fd-specific, sync', testPrintCompletion, fdFullOption, parentExecaSync);
51+
test('Prints completion, verbose "short", fd-specific stdout, sync', testPrintCompletion, stdoutShortOption, parentExecaSync);
52+
test('Prints completion, verbose "full", fd-specific stdout, sync', testPrintCompletion, stdoutFullOption, parentExecaSync);
53+
test('Prints completion, verbose "short", fd-specific stderr, sync', testPrintCompletion, stderrShortOption, parentExecaSync);
54+
test('Prints completion, verbose "full", fd-specific stderr, sync', testPrintCompletion, stderrFullOption, parentExecaSync);
55+
test('Prints completion, verbose "short", fd-specific fd3, sync', testPrintCompletion, fd3ShortOption, parentExecaSync);
56+
test('Prints completion, verbose "full", fd-specific fd3, sync', testPrintCompletion, fd3FullOption, parentExecaSync);
57+
test('Prints completion, verbose "short", fd-specific ipc, sync', testPrintCompletion, ipcShortOption, parentExecaSync);
58+
test('Prints completion, verbose "full", fd-specific ipc, sync', testPrintCompletion, ipcFullOption, parentExecaSync);
3859

3960
const testNoPrintCompletion = async (t, verbose, execaMethod) => {
4061
const {stderr} = await execaMethod('noop.js', [foobarString], {verbose});
@@ -43,11 +64,17 @@ const testNoPrintCompletion = async (t, verbose, execaMethod) => {
4364

4465
test('Does not print completion, verbose "none"', testNoPrintCompletion, 'none', parentExecaAsync);
4566
test('Does not print completion, verbose default"', testNoPrintCompletion, undefined, parentExecaAsync);
46-
test('Does not print completion, verbose "none", fd-specific', testNoPrintCompletion, fdNoneOption, parentExecaAsync);
67+
test('Does not print completion, verbose "none", fd-specific stdout', testNoPrintCompletion, stdoutNoneOption, parentExecaAsync);
68+
test('Does not print completion, verbose "none", fd-specific stderr', testNoPrintCompletion, stderrNoneOption, parentExecaAsync);
69+
test('Does not print completion, verbose "none", fd-specific fd3', testNoPrintCompletion, fd3NoneOption, parentExecaAsync);
70+
test('Does not print completion, verbose "none", fd-specific ipc', testNoPrintCompletion, ipcNoneOption, parentExecaAsync);
4771
test('Does not print completion, verbose default", fd-specific', testNoPrintCompletion, {}, parentExecaAsync);
4872
test('Does not print completion, verbose "none", sync', testNoPrintCompletion, 'none', parentExecaSync);
4973
test('Does not print completion, verbose default", sync', testNoPrintCompletion, undefined, parentExecaSync);
50-
test('Does not print completion, verbose "none", fd-specific, sync', testNoPrintCompletion, fdNoneOption, parentExecaSync);
74+
test('Does not print completion, verbose "none", fd-specific stdout, sync', testNoPrintCompletion, stdoutNoneOption, parentExecaSync);
75+
test('Does not print completion, verbose "none", fd-specific stderr, sync', testNoPrintCompletion, stderrNoneOption, parentExecaSync);
76+
test('Does not print completion, verbose "none", fd-specific fd3, sync', testNoPrintCompletion, fd3NoneOption, parentExecaSync);
77+
test('Does not print completion, verbose "none", fd-specific ipc, sync', testNoPrintCompletion, ipcNoneOption, parentExecaSync);
5178
test('Does not print completion, verbose default", fd-specific, sync', testNoPrintCompletion, {}, parentExecaSync);
5279

5380
const testPrintCompletionError = async (t, execaMethod) => {

test/verbose/error.js

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ import {
1414
getErrorLines,
1515
testTimestamp,
1616
getVerboseOption,
17-
fdNoneOption,
18-
fdShortOption,
19-
fdFullOption,
17+
stdoutNoneOption,
18+
stdoutShortOption,
19+
stdoutFullOption,
20+
stderrNoneOption,
21+
stderrShortOption,
22+
stderrFullOption,
23+
fd3NoneOption,
24+
fd3ShortOption,
25+
fd3FullOption,
26+
ipcNoneOption,
27+
ipcShortOption,
28+
ipcFullOption,
2029
} from '../helpers/verbose.js';
2130

2231
setFixtureDirectory();
@@ -30,12 +39,24 @@ const testPrintError = async (t, verbose, execaMethod) => {
3039

3140
test('Prints error, verbose "short"', testPrintError, 'short', runErrorSubprocessAsync);
3241
test('Prints error, verbose "full"', testPrintError, 'full', runErrorSubprocessAsync);
33-
test('Prints error, verbose "short", fd-specific', testPrintError, fdShortOption, runErrorSubprocessAsync);
34-
test('Prints error, verbose "full", fd-specific', testPrintError, fdFullOption, runErrorSubprocessAsync);
42+
test('Prints error, verbose "short", fd-specific stdout', testPrintError, stdoutShortOption, runErrorSubprocessAsync);
43+
test('Prints error, verbose "full", fd-specific stdout', testPrintError, stdoutFullOption, runErrorSubprocessAsync);
44+
test('Prints error, verbose "short", fd-specific stderr', testPrintError, stderrShortOption, runErrorSubprocessAsync);
45+
test('Prints error, verbose "full", fd-specific stderr', testPrintError, stderrFullOption, runErrorSubprocessAsync);
46+
test('Prints error, verbose "short", fd-specific fd3', testPrintError, fd3ShortOption, runErrorSubprocessAsync);
47+
test('Prints error, verbose "full", fd-specific fd3', testPrintError, fd3FullOption, runErrorSubprocessAsync);
48+
test('Prints error, verbose "short", fd-specific ipc', testPrintError, ipcShortOption, runErrorSubprocessAsync);
49+
test('Prints error, verbose "full", fd-specific ipc', testPrintError, ipcFullOption, runErrorSubprocessAsync);
3550
test('Prints error, verbose "short", sync', testPrintError, 'short', runErrorSubprocessSync);
3651
test('Prints error, verbose "full", sync', testPrintError, 'full', runErrorSubprocessSync);
37-
test('Prints error, verbose "short", fd-specific, sync', testPrintError, fdShortOption, runErrorSubprocessSync);
38-
test('Prints error, verbose "full", fd-specific, sync', testPrintError, fdFullOption, runErrorSubprocessSync);
52+
test('Prints error, verbose "short", fd-specific stdout, sync', testPrintError, stdoutShortOption, runErrorSubprocessSync);
53+
test('Prints error, verbose "full", fd-specific stdout, sync', testPrintError, stdoutFullOption, runErrorSubprocessSync);
54+
test('Prints error, verbose "short", fd-specific stderr, sync', testPrintError, stderrShortOption, runErrorSubprocessSync);
55+
test('Prints error, verbose "full", fd-specific stderr, sync', testPrintError, stderrFullOption, runErrorSubprocessSync);
56+
test('Prints error, verbose "short", fd-specific fd3, sync', testPrintError, fd3ShortOption, runErrorSubprocessSync);
57+
test('Prints error, verbose "full", fd-specific fd3, sync', testPrintError, fd3FullOption, runErrorSubprocessSync);
58+
test('Prints error, verbose "short", fd-specific ipc, sync', testPrintError, ipcShortOption, runErrorSubprocessSync);
59+
test('Prints error, verbose "full", fd-specific ipc, sync', testPrintError, ipcFullOption, runErrorSubprocessSync);
3960

4061
const testNoPrintError = async (t, verbose, execaMethod) => {
4162
const stderr = await execaMethod(t, verbose, false);
@@ -44,11 +65,17 @@ const testNoPrintError = async (t, verbose, execaMethod) => {
4465

4566
test('Does not print error, verbose "none"', testNoPrintError, 'none', runErrorSubprocessAsync);
4667
test('Does not print error, verbose default', testNoPrintError, undefined, runErrorSubprocessAsync);
47-
test('Does not print error, verbose "none", fd-specific', testNoPrintError, fdNoneOption, runErrorSubprocessAsync);
68+
test('Does not print error, verbose "none", fd-specific stdout', testNoPrintError, stdoutNoneOption, runErrorSubprocessAsync);
69+
test('Does not print error, verbose "none", fd-specific stderr', testNoPrintError, stderrNoneOption, runErrorSubprocessAsync);
70+
test('Does not print error, verbose "none", fd-specific fd3', testNoPrintError, fd3NoneOption, runErrorSubprocessAsync);
71+
test('Does not print error, verbose "none", fd-specific ipc', testNoPrintError, ipcNoneOption, runErrorSubprocessAsync);
4872
test('Does not print error, verbose default, fd-specific', testNoPrintError, {}, runErrorSubprocessAsync);
4973
test('Does not print error, verbose "none", sync', testNoPrintError, 'none', runErrorSubprocessSync);
5074
test('Does not print error, verbose default, sync', testNoPrintError, undefined, runErrorSubprocessSync);
51-
test('Does not print error, verbose "none", fd-specific, sync', testNoPrintError, fdNoneOption, runErrorSubprocessSync);
75+
test('Does not print error, verbose "none", fd-specific stdout, sync', testNoPrintError, stdoutNoneOption, runErrorSubprocessSync);
76+
test('Does not print error, verbose "none", fd-specific stderr, sync', testNoPrintError, stderrNoneOption, runErrorSubprocessSync);
77+
test('Does not print error, verbose "none", fd-specific fd3, sync', testNoPrintError, fd3NoneOption, runErrorSubprocessSync);
78+
test('Does not print error, verbose "none", fd-specific ipc, sync', testNoPrintError, ipcNoneOption, runErrorSubprocessSync);
5279
test('Does not print error, verbose default, fd-specific, sync', testNoPrintError, {}, runErrorSubprocessSync);
5380

5481
const testPrintNoError = async (t, execaMethod) => {

test/verbose/output-buffer.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import {parentExeca, parentExecaAsync, parentExecaSync} from '../helpers/nested.
55
import {
66
getOutputLine,
77
testTimestamp,
8-
fdFullOption,
9-
fdStderrFullOption,
8+
stdoutNoneOption,
9+
stdoutFullOption,
10+
stderrFullOption,
1011
} from '../helpers/verbose.js';
1112

1213
setFixtureDirectory();
@@ -18,20 +19,22 @@ const testPrintOutputNoBuffer = async (t, verbose, buffer, execaMethod) => {
1819

1920
test('Prints stdout, buffer: false', testPrintOutputNoBuffer, 'full', false, parentExecaAsync);
2021
test('Prints stdout, buffer: false, fd-specific buffer', testPrintOutputNoBuffer, 'full', {stdout: false}, parentExecaAsync);
21-
test('Prints stdout, buffer: false, fd-specific verbose', testPrintOutputNoBuffer, fdFullOption, false, parentExecaAsync);
22+
test('Prints stdout, buffer: false, fd-specific verbose', testPrintOutputNoBuffer, stdoutFullOption, false, parentExecaAsync);
2223
test('Prints stdout, buffer: false, sync', testPrintOutputNoBuffer, 'full', false, parentExecaSync);
2324
test('Prints stdout, buffer: false, fd-specific buffer, sync', testPrintOutputNoBuffer, 'full', {stdout: false}, parentExecaSync);
24-
test('Prints stdout, buffer: false, fd-specific verbose, sync', testPrintOutputNoBuffer, fdFullOption, false, parentExecaSync);
25+
test('Prints stdout, buffer: false, fd-specific verbose, sync', testPrintOutputNoBuffer, stdoutFullOption, false, parentExecaSync);
2526

26-
const testPrintOutputNoBufferFalse = async (t, buffer, execaMethod) => {
27-
const {stderr} = await execaMethod('noop.js', [foobarString], {verbose: fdStderrFullOption, buffer});
27+
const testPrintOutputNoBufferFalse = async (t, verbose, buffer, execaMethod) => {
28+
const {stderr} = await execaMethod('noop.js', [foobarString], {verbose, buffer});
2829
t.is(getOutputLine(stderr), undefined);
2930
};
3031

31-
test('Does not print stdout, buffer: false, different fd', testPrintOutputNoBufferFalse, false, parentExecaAsync);
32-
test('Does not print stdout, buffer: false, different fd, fd-specific buffer', testPrintOutputNoBufferFalse, {stdout: false}, parentExecaAsync);
33-
test('Does not print stdout, buffer: false, different fd, sync', testPrintOutputNoBufferFalse, false, parentExecaSync);
34-
test('Does not print stdout, buffer: false, different fd, fd-specific buffer, sync', testPrintOutputNoBufferFalse, {stdout: false}, parentExecaSync);
32+
test('Does not print stdout, buffer: false, fd-specific none', testPrintOutputNoBufferFalse, stdoutNoneOption, false, parentExecaAsync);
33+
test('Does not print stdout, buffer: false, different fd', testPrintOutputNoBufferFalse, stderrFullOption, false, parentExecaAsync);
34+
test('Does not print stdout, buffer: false, different fd, fd-specific buffer', testPrintOutputNoBufferFalse, stderrFullOption, {stdout: false}, parentExecaAsync);
35+
test('Does not print stdout, buffer: false, fd-specific none, sync', testPrintOutputNoBufferFalse, stdoutNoneOption, false, parentExecaSync);
36+
test('Does not print stdout, buffer: false, different fd, sync', testPrintOutputNoBufferFalse, stderrFullOption, false, parentExecaSync);
37+
test('Does not print stdout, buffer: false, different fd, fd-specific buffer, sync', testPrintOutputNoBufferFalse, stderrFullOption, {stdout: false}, parentExecaSync);
3538

3639
const testPrintOutputNoBufferTransform = async (t, buffer, isSync) => {
3740
const {stderr} = await parentExeca('nested-transform.js', 'noop.js', [foobarString], {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy