clean up and rename things to follow proper conventions
This commit is contained in:
parent
3e6d23928b
commit
cc2dfaf5d8
18 changed files with 52 additions and 68 deletions
8
lib/codeql.js
generated
8
lib/codeql.js
generated
|
|
@ -22,8 +22,8 @@ const globalutil = __importStar(require("util"));
|
|||
const v4_1 = __importDefault(require("uuid/v4"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||
const error_matcher_1 = require("./error_matcher");
|
||||
const exec_wrapper_1 = require("./exec_wrapper");
|
||||
const error_matcher_1 = require("./error-matcher");
|
||||
const exec_wrapper_1 = require("./exec-wrapper");
|
||||
const util = __importStar(require("./util"));
|
||||
/**
|
||||
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
|
||||
|
|
@ -290,7 +290,7 @@ function getCodeQLForCmd(cmd) {
|
|||
const ext = process.platform === 'win32' ? '.cmd' : '.sh';
|
||||
const traceCommand = path.resolve(JSON.parse(extractorPath), 'tools', 'autobuild' + ext);
|
||||
// Run trace command
|
||||
await exec_wrapper_1.exec_wrapper(cmd, [
|
||||
await exec_wrapper_1.execErrorCatcher(cmd, [
|
||||
'database',
|
||||
'trace-command',
|
||||
...getExtraOptionsFromEnv(['database', 'trace-command']),
|
||||
|
|
@ -300,7 +300,7 @@ function getCodeQLForCmd(cmd) {
|
|||
], error_matcher_1.errorMatchers);
|
||||
},
|
||||
finalizeDatabase: async function (databasePath) {
|
||||
await exec_wrapper_1.exec_wrapper(cmd, [
|
||||
await exec_wrapper_1.execErrorCatcher(cmd, [
|
||||
'database',
|
||||
'finalize',
|
||||
...getExtraOptionsFromEnv(['database', 'finalize']),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
lib/error_matcher.js → lib/error-matcher.js
generated
4
lib/error_matcher.js → lib/error-matcher.js
generated
|
|
@ -13,6 +13,6 @@ exports.namedMatchersForTesting = {
|
|||
https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build`
|
||||
],
|
||||
};
|
||||
// we collapse the matches into an array for use in exec_wrapper
|
||||
// we collapse the matches into an array for use in execErrorCatcher
|
||||
exports.errorMatchers = Object.values(exports.namedMatchersForTesting);
|
||||
//# sourceMappingURL=error_matcher.js.map
|
||||
//# sourceMappingURL=error-matcher.js.map
|
||||
1
lib/error-matcher.js.map
Normal file
1
lib/error-matcher.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"error-matcher.js","sourceRoot":"","sources":["../src/error-matcher.ts"],"names":[],"mappings":";;AAGA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;;MAGE;IACF,iBAAiB,EAAE;QACjB,EAAE;QACF,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACvD;wJACoJ;KACrJ;CACF,CAAC;AAEF,oEAAoE;AACvD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
||||
|
|
@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const error_matcher_1 = require("./error_matcher");
|
||||
const error_matcher_1 = require("./error-matcher");
|
||||
/*
|
||||
NB We test the regexes for all the matchers against example log output snippets.
|
||||
*/
|
||||
|
|
@ -30,4 +30,4 @@ function testErrorMatcher(matcherName, logSample) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=error_matcher.test.js.map
|
||||
//# sourceMappingURL=error-matcher.test.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"error_matcher.test.js","sourceRoot":"","sources":["../src/error_matcher.test.ts"],"names":[],"mappings":";;;;;AACA,8CAAuB;AAEvB,mDAA0D;AAE1D;;EAEE;AAEF,aAAI,CAAC,6DAA6D,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC5E,CAAC,CA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KAAK,CAAC,uBAAuB,WAAW,kBAAkB,CAAC,CAAC;SACvE;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,mBAAmB,WAAW,EAAE,CAAC,CAAC;SACnD;KACF;AAEH,CAAC"}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"error_matcher.js","sourceRoot":"","sources":["../src/error_matcher.ts"],"names":[],"mappings":";;AAGA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;;MAGE;IACF,iBAAiB,EAAE;QACjB,EAAE;QACF,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACvD;wJACoJ;KACrJ;CACF,CAAC;AAEF,gEAAgE;AACnD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
||||
6
lib/exec_wrapper.js → lib/exec-wrapper.js
generated
6
lib/exec_wrapper.js → lib/exec-wrapper.js
generated
|
|
@ -19,7 +19,7 @@ const exec = __importStar(require("@actions/exec"));
|
|||
* @param options optional exec options. See ExecOptions
|
||||
* @returns Promise<number> exit code
|
||||
*/
|
||||
async function exec_wrapper(commandLine, args, matchers, options) {
|
||||
async function execErrorCatcher(commandLine, args, matchers, options) {
|
||||
var _a;
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
|
@ -82,5 +82,5 @@ async function exec_wrapper(commandLine, args, matchers, options) {
|
|||
throw returnState;
|
||||
}
|
||||
}
|
||||
exports.exec_wrapper = exec_wrapper;
|
||||
//# sourceMappingURL=exec_wrapper.js.map
|
||||
exports.execErrorCatcher = execErrorCatcher;
|
||||
//# sourceMappingURL=exec-wrapper.js.map
|
||||
1
lib/exec-wrapper.js.map
Normal file
1
lib/exec-wrapper.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"exec-wrapper.js","sourceRoot":"","sources":["../src/exec-wrapper.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAKtC;;;;;;;;;;GAUG;AACI,KAAK,UAA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AU,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE;YACnD,IAAI,UAAU,KAAK,WAAW,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAG;gBACtF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1B;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,UAAI,OAAO,0CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,4BAA4B,WAAW,EAAE,CAAC,CAAC;SACxF;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAjED,4CAiEC"}
|
||||
33
lib/exec_wrapper.test.js → lib/exec-wrapper.test.js
generated
33
lib/exec_wrapper.test.js → lib/exec-wrapper.test.js
generated
|
|
@ -12,33 +12,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const exec_wrapper_1 = require("./exec_wrapper");
|
||||
const exec_wrapper_1 = require("./exec-wrapper");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
// import fs from 'fs';
|
||||
// import { exec_wrapper } from './exec_wrapper';
|
||||
// const matchers: [[number, RegExp, string]] = [
|
||||
// [-999,
|
||||
// new RegExp("match this string"),
|
||||
// 'No source code was found. CUSTOM ERROR MESSAGE HERE'],
|
||||
// ];
|
||||
testing_utils_1.setupTests(ava_1.default);
|
||||
ava_1.default('matchers are never applied if non-error exit', async (t) => {
|
||||
const testCommand = buildDummyCommand("foo bar\\nblort qux", "foo bar\\nblort qux", '', 0);
|
||||
const matchers = [[123, new RegExp("foo bar"), 'error!!!']];
|
||||
t.deepEqual(await exec.exec(testCommand), 0);
|
||||
t.deepEqual(await exec_wrapper_1.exec_wrapper(testCommand, [], matchers), 0);
|
||||
t.deepEqual(await exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), 0);
|
||||
});
|
||||
ava_1.default('regex matchers are applied to stdout for non-zero exit code', async (t) => {
|
||||
const testCommand = buildDummyCommand("foo bar\\nblort qux", '', '', 1);
|
||||
const matchers = [[123, new RegExp("foo bar"), '🦄']];
|
||||
await t.throwsAsync(exec.exec(testCommand), { instanceOf: Error, message: 'The process \'node\' failed with exit code 1' });
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
});
|
||||
ava_1.default('regex matchers are applied to stderr for non-zero exit code', async (t) => {
|
||||
const testCommand = buildDummyCommand("non matching string", 'foo bar\\nblort qux', '', 1);
|
||||
const matchers = [[123, new RegExp("foo bar"), '🦄']];
|
||||
await t.throwsAsync(exec.exec(testCommand), { instanceOf: Error, message: 'The process \'node\' failed with exit code 1' });
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
});
|
||||
ava_1.default('matcher returns correct error message when multiple matchers defined', async (t) => {
|
||||
const testCommand = buildDummyCommand("non matching string", 'foo bar\\nblort qux', '', 1);
|
||||
|
|
@ -46,7 +39,7 @@ ava_1.default('matcher returns correct error message when multiple matchers defi
|
|||
[123, new RegExp("foo bar"), '🦄'],
|
||||
[789, new RegExp("blah blah"), '🤦♂️']];
|
||||
await t.throwsAsync(exec.exec(testCommand), { instanceOf: Error, message: 'The process \'node\' failed with exit code 1' });
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
});
|
||||
ava_1.default('matcher returns first match to regex when multiple matches', async (t) => {
|
||||
const testCommand = buildDummyCommand("non matching string", 'foo bar\\nblort qux', '', 1);
|
||||
|
|
@ -54,20 +47,20 @@ ava_1.default('matcher returns first match to regex when multiple matches', asyn
|
|||
[789, new RegExp("blah blah"), '🤦♂️'],
|
||||
[987, new RegExp("foo bar"), '🚫']];
|
||||
await t.throwsAsync(exec.exec(testCommand), { instanceOf: Error, message: 'The process \'node\' failed with exit code 1' });
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
});
|
||||
ava_1.default('exit code matchers are applied', async (t) => {
|
||||
const testCommand = buildDummyCommand("non matching string", 'foo bar\\nblort qux', '', 123);
|
||||
const matchers = [[123, new RegExp("this will not match"), '🦄']];
|
||||
await t.throwsAsync(exec.exec(testCommand), { instanceOf: Error, message: 'The process \'node\' failed with exit code 123' });
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], matchers), { instanceOf: Error, message: '🦄' });
|
||||
});
|
||||
ava_1.default('exec_wrapper respects the ignoreReturnValue option', async (t) => {
|
||||
ava_1.default('execErrorCatcher respects the ignoreReturnValue option', async (t) => {
|
||||
const testCommand = buildDummyCommand("standard output", 'error output', '', 199);
|
||||
await t.throwsAsync(exec_wrapper_1.exec_wrapper(testCommand, [], [], { ignoreReturnCode: false }), { instanceOf: Error });
|
||||
t.deepEqual(await exec_wrapper_1.exec_wrapper(testCommand, [], [], { ignoreReturnCode: true }), 199);
|
||||
await t.throwsAsync(exec_wrapper_1.execErrorCatcher(testCommand, [], [], { ignoreReturnCode: false }), { instanceOf: Error });
|
||||
t.deepEqual(await exec_wrapper_1.execErrorCatcher(testCommand, [], [], { ignoreReturnCode: true }), 199);
|
||||
});
|
||||
ava_1.default('exec_wrapper preserves behavior of provided listeners', async (t) => {
|
||||
ava_1.default('execErrorCatcher preserves behavior of provided listeners', async (t) => {
|
||||
let stdoutExpected = 'standard output';
|
||||
let stderrExpected = 'error output';
|
||||
let stdoutActual = '';
|
||||
|
|
@ -81,7 +74,7 @@ ava_1.default('exec_wrapper preserves behavior of provided listeners', async (t)
|
|||
}
|
||||
};
|
||||
const testCommand = buildDummyCommand(stdoutExpected, stderrExpected, '', 0);
|
||||
t.deepEqual(await exec_wrapper_1.exec_wrapper(testCommand, [], [], { listeners: listeners }), 0);
|
||||
t.deepEqual(await exec_wrapper_1.execErrorCatcher(testCommand, [], [], { listeners: listeners }), 0);
|
||||
t.deepEqual(stdoutActual, stdoutExpected + "\n");
|
||||
t.deepEqual(stderrActual, stderrExpected + "\n");
|
||||
});
|
||||
|
|
@ -99,4 +92,4 @@ function buildDummyCommand(stdoutContents, stderrContents, desiredErrorMessage,
|
|||
command += 'process.exitCode = ' + desiredExitCode + ';';
|
||||
return 'node -e "' + command + '"';
|
||||
}
|
||||
//# sourceMappingURL=exec_wrapper.test.js.map
|
||||
//# sourceMappingURL=exec-wrapper.test.js.map
|
||||
1
lib/exec-wrapper.test.js.map
Normal file
1
lib/exec-wrapper.test.js.map
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"exec_wrapper.js","sourceRoot":"","sources":["../src/exec_wrapper.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAKtC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAAC,WAAmB,EAAE,IAAe,EACpC,QAAyB,EACzB,OAAwB;;IAEzD,IAAI,MAAM,GAAG,EAAE,CA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AI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAG;gBACtF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1B;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,UAAI,OAAO,0CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,4BAA4B,WAAW,EAAE,CAAC,CAAC;SACxF;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAjED,oCAiEC"}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -12,8 +12,8 @@ import uuidV4 from 'uuid/v4';
|
|||
|
||||
import * as api from './api-client';
|
||||
import * as defaults from './defaults.json'; // Referenced from codeql-action-sync-tool!
|
||||
import { errorMatchers} from './error_matcher';
|
||||
import { exec_wrapper } from './exec_wrapper';
|
||||
import { errorMatchers} from './error-matcher';
|
||||
import { execErrorCatcher } from './exec-wrapper';
|
||||
import { Language } from './languages';
|
||||
import * as util from './util';
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||
const traceCommand = path.resolve(JSON.parse(extractorPath), 'tools', 'autobuild' + ext);
|
||||
|
||||
// Run trace command
|
||||
await exec_wrapper(
|
||||
await execErrorCatcher(
|
||||
cmd, [
|
||||
'database',
|
||||
'trace-command',
|
||||
|
|
@ -395,7 +395,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||
);
|
||||
},
|
||||
finalizeDatabase: async function(databasePath: string) {
|
||||
await exec_wrapper(
|
||||
await execErrorCatcher(
|
||||
cmd, [
|
||||
'database',
|
||||
'finalize',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import test from 'ava';
|
||||
|
||||
import { namedMatchersForTesting } from './error_matcher';
|
||||
import { namedMatchersForTesting } from './error-matcher';
|
||||
|
||||
/*
|
||||
NB We test the regexes for all the matchers against example log output snippets.
|
||||
|
|
@ -15,5 +15,5 @@ https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in
|
|||
],
|
||||
};
|
||||
|
||||
// we collapse the matches into an array for use in exec_wrapper
|
||||
// we collapse the matches into an array for use in execErrorCatcher
|
||||
export const errorMatchers = Object.values(namedMatchersForTesting);
|
||||
|
|
@ -1,18 +1,9 @@
|
|||
import * as exec from '@actions/exec';
|
||||
import test from 'ava';
|
||||
|
||||
import { ErrorMatcher } from './error_matcher';
|
||||
import { exec_wrapper } from './exec_wrapper';
|
||||
import { ErrorMatcher } from './error-matcher';
|
||||
import { execErrorCatcher } from './exec-wrapper';
|
||||
import {setupTests} from './testing-utils';
|
||||
// import fs from 'fs';
|
||||
|
||||
// import { exec_wrapper } from './exec_wrapper';
|
||||
|
||||
// const matchers: [[number, RegExp, string]] = [
|
||||
// [-999,
|
||||
// new RegExp("match this string"),
|
||||
// 'No source code was found. CUSTOM ERROR MESSAGE HERE'],
|
||||
// ];
|
||||
|
||||
setupTests(test);
|
||||
|
||||
|
|
@ -24,7 +15,7 @@ test('matchers are never applied if non-error exit', async t => {
|
|||
|
||||
t.deepEqual(await exec.exec(testCommand), 0);
|
||||
|
||||
t.deepEqual(await exec_wrapper(testCommand, [], matchers), 0);
|
||||
t.deepEqual(await execErrorCatcher(testCommand, [], matchers), 0);
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -37,7 +28,7 @@ test('regex matchers are applied to stdout for non-zero exit code', async t => {
|
|||
await t.throwsAsync(exec.exec(testCommand), {instanceOf: Error, message: 'The process \'node\' failed with exit code 1'});
|
||||
|
||||
await t.throwsAsync(
|
||||
exec_wrapper(testCommand, [], matchers),
|
||||
execErrorCatcher(testCommand, [], matchers),
|
||||
{instanceOf: Error, message: '🦄'}
|
||||
);
|
||||
|
||||
|
|
@ -52,7 +43,7 @@ test('regex matchers are applied to stderr for non-zero exit code', async t => {
|
|||
await t.throwsAsync(exec.exec(testCommand), {instanceOf: Error, message: 'The process \'node\' failed with exit code 1'});
|
||||
|
||||
await t.throwsAsync(
|
||||
exec_wrapper(testCommand, [], matchers),
|
||||
execErrorCatcher(testCommand, [], matchers),
|
||||
{instanceOf: Error, message: '🦄'}
|
||||
);
|
||||
|
||||
|
|
@ -69,7 +60,7 @@ test('matcher returns correct error message when multiple matchers defined', asy
|
|||
await t.throwsAsync(exec.exec(testCommand), {instanceOf: Error, message: 'The process \'node\' failed with exit code 1'});
|
||||
|
||||
await t.throwsAsync(
|
||||
exec_wrapper(testCommand, [], matchers),
|
||||
execErrorCatcher(testCommand, [], matchers),
|
||||
{instanceOf: Error, message: '🦄'}
|
||||
);
|
||||
|
||||
|
|
@ -86,7 +77,7 @@ test('matcher returns first match to regex when multiple matches', async t => {
|
|||
await t.throwsAsync(exec.exec(testCommand), {instanceOf: Error, message: 'The process \'node\' failed with exit code 1'});
|
||||
|
||||
await t.throwsAsync(
|
||||
exec_wrapper(testCommand, [], matchers),
|
||||
execErrorCatcher(testCommand, [], matchers),
|
||||
{instanceOf: Error, message: '🦄'}
|
||||
);
|
||||
|
||||
|
|
@ -101,22 +92,22 @@ test('exit code matchers are applied', async t => {
|
|||
await t.throwsAsync(exec.exec(testCommand), {instanceOf: Error, message: 'The process \'node\' failed with exit code 123'});
|
||||
|
||||
await t.throwsAsync(
|
||||
exec_wrapper(testCommand, [], matchers),
|
||||
execErrorCatcher(testCommand, [], matchers),
|
||||
{instanceOf: Error, message: '🦄'}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
test('exec_wrapper respects the ignoreReturnValue option', async t => {
|
||||
test('execErrorCatcher respects the ignoreReturnValue option', async t => {
|
||||
const testCommand = buildDummyCommand("standard output", 'error output', '', 199);
|
||||
|
||||
await t.throwsAsync(exec_wrapper(testCommand, [], [], {ignoreReturnCode: false}), {instanceOf: Error});
|
||||
await t.throwsAsync(execErrorCatcher(testCommand, [], [], {ignoreReturnCode: false}), {instanceOf: Error});
|
||||
|
||||
t.deepEqual(await exec_wrapper(testCommand, [], [], {ignoreReturnCode: true}), 199);
|
||||
t.deepEqual(await execErrorCatcher(testCommand, [], [], {ignoreReturnCode: true}), 199);
|
||||
|
||||
});
|
||||
|
||||
test('exec_wrapper preserves behavior of provided listeners', async t => {
|
||||
test('execErrorCatcher preserves behavior of provided listeners', async t => {
|
||||
|
||||
let stdoutExpected = 'standard output';
|
||||
let stderrExpected = 'error output';
|
||||
|
|
@ -135,7 +126,7 @@ test('exec_wrapper preserves behavior of provided listeners', async t => {
|
|||
|
||||
const testCommand = buildDummyCommand(stdoutExpected, stderrExpected, '', 0);
|
||||
|
||||
t.deepEqual(await exec_wrapper(testCommand, [], [], {listeners: listeners}), 0);
|
||||
t.deepEqual(await execErrorCatcher(testCommand, [], [], {listeners: listeners}), 0);
|
||||
|
||||
t.deepEqual(stdoutActual, stdoutExpected + "\n");
|
||||
t.deepEqual(stderrActual, stderrExpected + "\n");
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import * as exec from '@actions/exec';
|
||||
import * as im from '@actions/exec/lib/interfaces';
|
||||
|
||||
import {ErrorMatcher} from './error_matcher';
|
||||
import {ErrorMatcher} from './error-matcher';
|
||||
|
||||
/**
|
||||
* Wrapper for exec.exec which checks for specific return code and/or regex matches in console output.
|
||||
|
|
@ -14,9 +14,9 @@ import {ErrorMatcher} from './error_matcher';
|
|||
* @param options optional exec options. See ExecOptions
|
||||
* @returns Promise<number> exit code
|
||||
*/
|
||||
export async function exec_wrapper(commandLine: string, args?: string[],
|
||||
matchers?: ErrorMatcher[],
|
||||
options?: im.ExecOptions): Promise<number> {
|
||||
export async function execErrorCatcher(commandLine: string, args?: string[],
|
||||
matchers?: ErrorMatcher[],
|
||||
options?: im.ExecOptions): Promise<number> {
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
Loading…
Add table
Add a link
Reference in a new issue