Add extra integration test for packaging

Also, update the options and inputs documentation.
This commit is contained in:
Andrew Eisenberg 2021-06-24 14:50:34 -07:00
parent 6e577cfca3
commit 4087f37d90
11 changed files with 83 additions and 21 deletions

10
lib/config-utils.js generated
View file

@ -425,7 +425,7 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
if (queriesInput) {
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
}
const packs = (_a = parsePacksInput(packsInput, languages), (_a !== null && _a !== void 0 ? _a : {}));
const packs = (_a = parsePacksFromInput(packsInput, languages), (_a !== null && _a !== void 0 ? _a : {}));
return {
languages,
queries,
@ -584,13 +584,13 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
return packs;
}
exports.parsePacksFromConfig = parsePacksFromConfig;
function parsePacksInput(packsInput, languages) {
function parsePacksFromInput(packsInput, languages) {
var _a;
if (!((_a = packsInput) === null || _a === void 0 ? void 0 : _a.trim())) {
return undefined;
}
if (languages.length > 1) {
throw new Error("Cannot specify a 'packs' input in a multi-language analysis. Use a codeql-config.yml file instead and specify packs by library.");
throw new Error("Cannot specify a 'packs' input in a multi-language analysis. Use a codeql-config.yml file instead and specify packs by language.");
}
else if (languages.length === 0) {
throw new Error("No languages specified. Cannot process the packs input.");
@ -599,7 +599,7 @@ function parsePacksInput(packsInput, languages) {
if (packsInput.startsWith("+")) {
packsInput = packsInput.substring(1).trim();
if (!packsInput) {
throw new Error("Remove the '+' from the packs input.");
throw new Error("A '+' was used in the 'packs' input to specify that you wished to add some packs to your CodeQL analysis. However, no packs were specified. Please either remove the '+' or specify some packs.");
}
}
return {
@ -632,7 +632,7 @@ function toPackWithVersion(packStr, configFile) {
}
// exported for testing
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
const packsFromInput = parsePacksInput(rawPacksInput, languages);
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
if (!packsFromInput) {
return packsFomConfig;

File diff suppressed because one or more lines are too long

View file

@ -852,7 +852,7 @@ ava_1.default("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e
});
ava_1.default("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
ava_1.default("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
ava_1.default("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /Remove the '\+'/);
ava_1.default("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /remove the '\+'/);
ava_1.default("input with invalid pack name", parseInputAndConfigErrorMacro, {}, " xxx", [languages_1.Language.cpp], /"xxx" is not a valid pack/);
// errors
// input w invalid pack name

5
lib/runner.js generated
View file

@ -90,11 +90,12 @@ program
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
.option("--packs <packs>", `Comma-separated list of packs to run. Reference a pack in the format scope/name[@version]. If version is not
.option("--packs <packs>", `[Experimental] Comma-separated list of packs to run. Reference a pack in the format scope/name[@version]. If version is not
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
configuration file; prefix with "+" to use both sets of packs.
This option is only available in single-language analyses.`)
This option is only available in single-language analyses. To use packs in multi-language
analyses, you must specify packs in the codeql-config.yml file.`)
.option("--config-file <file>", "Path to config file.")
.option("--codeql-path <path>", "Path to a copy of the CodeQL CLI executable to use. Otherwise downloads a copy.")
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')

File diff suppressed because one or more lines are too long