Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): tolerate #2702 stderr noise #2704

Open
wants to merge 1 commit into
base: markm-fix2700-ignore-safe-asynchook-extras
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/cli/test/_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
* Transforms a testRoutine into an ava test.
* The testCommand function asserts that a given awaitable command produces the expected stdout and stderr.
*
* An absent `expectation.stdout` defaults to the empty string.
* An absent `expectation.stderr` now defaults to an accept-anything regexp
* in order to tolerate extra tool-generated noise that happens, for example,
* when run under a vscode JavaScript Debug Terminal
* @see https://github.com/endojs/endo/issues/2702
*
* @param {Execa} execa - the command execution environment
* @param {TestRoutine} testRoutine - the test logic implementation
* @returns {(t: t) => Promise<void>}
Expand All @@ -15,16 +21,16 @@ export function makeSectionTest(execa, testRoutine) {
const matchExpecation = (expectation, result, errMsg) => {
(expectation instanceof RegExp ? t.regex : t.is)(
result,
expectation ?? '',
expectation,
errMsg,
);
};
const testCommand = async (command, expectation) => {
const result = await command;
if (expectation !== undefined) {
const errMsg = JSON.stringify({ expectation, result }, null, 2);
matchExpecation(expectation.stdout, result.stdout, errMsg);
matchExpecation(expectation.stderr, result.stderr, errMsg);
matchExpecation(expectation.stdout ?? '', result.stdout, errMsg);
matchExpecation(expectation.stderr ?? /.*/, result.stderr, errMsg);
}
};
await testRoutine(execa, testCommand);
Expand Down
Loading