Skip to content

Commit 75c7164

Browse files
committed
fix(cli): tolerate #2702 stderr noise
1 parent 76012d0 commit 75c7164

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/cli/test/_section.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
* Transforms a testRoutine into an ava test.
77
* The testCommand function asserts that a given awaitable command produces the expected stdout and stderr.
88
*
9+
* An absent `expectation.stdout` defaults to the empty string.
10+
* An absent `expectation.stderr` now defaults to an accept-anything regexp
11+
* in order to tolerate extra tool-generated noise that happens, for example,
12+
* when run under a vscode JavaScript Debug Terminal
13+
* @see https://github.com/endojs/endo/issues/2702
14+
*
915
* @param {Execa} execa - the command execution environment
1016
* @param {TestRoutine} testRoutine - the test logic implementation
1117
* @returns {(t: t) => Promise<void>}
@@ -15,16 +21,16 @@ export function makeSectionTest(execa, testRoutine) {
1521
const matchExpecation = (expectation, result, errMsg) => {
1622
(expectation instanceof RegExp ? t.regex : t.is)(
1723
result,
18-
expectation ?? '',
24+
expectation,
1925
errMsg,
2026
);
2127
};
2228
const testCommand = async (command, expectation) => {
2329
const result = await command;
2430
if (expectation !== undefined) {
2531
const errMsg = JSON.stringify({ expectation, result }, null, 2);
26-
matchExpecation(expectation.stdout, result.stdout, errMsg);
27-
matchExpecation(expectation.stderr, result.stderr, errMsg);
32+
matchExpecation(expectation.stdout ?? '', result.stdout, errMsg);
33+
matchExpecation(expectation.stderr ?? /.*/, result.stderr, errMsg);
2834
}
2935
};
3036
await testRoutine(execa, testCommand);

0 commit comments

Comments
 (0)