add missing error case for exit code matching

This commit is contained in:
Nick Fyson
2020-09-15 15:30:54 +01:00
parent 1ca9d4c096
commit b6b88b1d75
3 changed files with 61 additions and 1 deletions
+25
View File
@@ -23,6 +23,31 @@ ava_1.default("matchers are never applied if non-error exit", async (t) => {
t.deepEqual(await exec.exec("node", testArgs), 0);
t.deepEqual(await toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), 0);
});
ava_1.default("exit code matching is correctly handled", async (t) => {
const testArgs = buildDummyArgs("foo bar\\nblort qux", "foo bar\\nblort qux", "", 42);
const nonMatchers = [
{
exitCode: 123,
outputRegex: new RegExp("will not match"),
message: "custom message!",
},
];
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, nonMatchers), {
instanceOf: Error,
message: "The process 'node' failed with exit code 42",
});
const matchers = [
{
exitCode: 42,
outputRegex: new RegExp("will not match"),
message: "custom message!",
},
];
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
instanceOf: Error,
message: "custom message!",
});
});
ava_1.default("regex matchers are applied to stdout for non-zero exit code", async (t) => {
const testArgs = buildDummyArgs("foo bar\\nblort qux", "", "", 1);
const matchers = [
File diff suppressed because one or more lines are too long