Rename VersionOutput to VersionInfo
This commit is contained in:
parent
49b94f1a2d
commit
bcbb900532
19 changed files with 60 additions and 68 deletions
2
lib/analyze.test.js
generated
2
lib/analyze.test.js
generated
|
|
@ -214,7 +214,7 @@ const util = __importStar(require("./util"));
|
|||
});
|
||||
function mockCodeQL() {
|
||||
return {
|
||||
getVersion: async () => (0, testing_utils_1.makeVersionOutput)("1.0.0"),
|
||||
getVersion: async () => (0, testing_utils_1.makeVersionInfo)("1.0.0"),
|
||||
databaseRunQueries: sinon.spy(),
|
||||
databaseInterpretResults: async () => "",
|
||||
databasePrintBaseline: async () => "",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
30
lib/codeql.test.js
generated
30
lib/codeql.test.js
generated
|
|
@ -377,9 +377,7 @@ for (const isBundleVersionInUrl of [true, false]) {
|
|||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)("2.10.5"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.10.5"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
const thisStubConfig = {
|
||||
|
|
@ -405,7 +403,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)(feature_flags_1.featureConfig[feature_flags_1.Feature.CliConfigFileEnabled].minimumVersion ||
|
||||
.resolves((0, testing_utils_1.makeVersionInfo)(feature_flags_1.featureConfig[feature_flags_1.Feature.CliConfigFileEnabled].minimumVersion ||
|
||||
"1.0.0"));
|
||||
const thisStubConfig = {
|
||||
...stubConfig,
|
||||
|
|
@ -549,7 +547,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
// stubbed version doesn't matter. It just needs to be valid semver.
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("0.0.0"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("0.0.0"));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, (0, testing_utils_1.createFeatures)([]), "/path/to/qlconfig.yml", (0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should not have used a config file
|
||||
|
|
@ -566,7 +564,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
.resolves((0, testing_utils_1.makeVersionInfo)(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CliConfigFileEnabled]), "/path/to/qlconfig.yml", (0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used a config file
|
||||
|
|
@ -581,9 +579,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)("2.12.2"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.2"));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CliConfigFileEnabled]), "/path/to/qlconfig.yml", (0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
// should have used a config file
|
||||
|
|
@ -600,7 +596,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
.resolves((0, testing_utils_1.makeVersionInfo)(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CliConfigFileEnabled]), undefined, // undefined qlconfigFile
|
||||
(0, logging_1.getRunnerLogger)(true));
|
||||
const args = runnerConstructorStub.firstCall.args[1];
|
||||
|
|
@ -611,7 +607,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.11.3"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.11.3"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||
|
|
@ -620,7 +616,7 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.11.2"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.11.2"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||
|
|
@ -656,7 +652,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves((0, testing_utils_1.makeVersionOutput)(codeqlVersion));
|
||||
.resolves((0, testing_utils_1.makeVersionInfo)(codeqlVersion));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)(featureEnabled ? [feature_flags_1.Feature.AnalysisSummaryV2Enabled] : []), (0, logging_1.getRunnerLogger)(true));
|
||||
|
|
@ -670,7 +666,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
|
|||
2020-09-07T17:39:53.9052444Z [2020-09-07 17:39:53] [build-err] No JavaScript or TypeScript code found.
|
||||
2020-09-07T17:39:53.9251124Z [2020-09-07 17:39:53] [ERROR] Spawned process exited abnormally (code 255; tried to run: [/opt/hostedtoolcache/CodeQL/0.0.0-20200630/x64/codeql/javascript/tools/autobuild.sh])`);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("", "", ""), {
|
||||
|
|
@ -681,7 +677,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
|
|||
(0, ava_1.default)("database finalize overrides no code found error on CodeQL 2.11.6", async (t) => {
|
||||
stubToolRunnerConstructor(32);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("", "", ""), {
|
||||
|
|
@ -694,7 +690,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
|
|||
"https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build.";
|
||||
stubToolRunnerConstructor(32, cliMessage);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"), {
|
||||
|
|
@ -709,7 +705,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
|
|||
`${heapError}\n${datasetImportError}.`;
|
||||
stubToolRunnerConstructor(32, cliStderr);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionOutput)("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"), {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
lib/config-utils.test.js
generated
4
lib/config-utils.test.js
generated
|
|
@ -1177,7 +1177,7 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
|
|||
});
|
||||
const codeQL = (0, codeql_1.setCodeQL)({
|
||||
packDownload: packDownloadStub,
|
||||
getVersion: () => Promise.resolve((0, testing_utils_1.makeVersionOutput)("2.10.5")),
|
||||
getVersion: () => Promise.resolve((0, testing_utils_1.makeVersionInfo)("2.10.5")),
|
||||
});
|
||||
// packs are supplied for go, java, and python
|
||||
// analyzed languages are java, javascript, and python
|
||||
|
|
@ -1221,7 +1221,7 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
|
|||
},
|
||||
]);
|
||||
const codeQL = (0, codeql_1.setCodeQL)({
|
||||
getVersion: () => Promise.resolve((0, testing_utils_1.makeVersionOutput)("2.10.4")),
|
||||
getVersion: () => Promise.resolve((0, testing_utils_1.makeVersionInfo)("2.10.4")),
|
||||
});
|
||||
await t.throwsAsync(async () => {
|
||||
return await configUtils.downloadPacks(codeQL, [languages_1.Language.javascript, languages_1.Language.java, languages_1.Language.python], {}, sampleApiDetails, registriesInput, tmpDir, logger);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
10
lib/testing-utils.js
generated
10
lib/testing-utils.js
generated
|
|
@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionOutput = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
|
||||
exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionInfo = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
|
||||
const node_util_1 = require("node:util");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const github = __importStar(require("@actions/github"));
|
||||
|
|
@ -188,16 +188,16 @@ function mockLanguagesInRepo(languages) {
|
|||
}
|
||||
exports.mockLanguagesInRepo = mockLanguagesInRepo;
|
||||
/**
|
||||
* Constructs a `VersionOutput` object for testing purposes only.
|
||||
* Constructs a `VersionInfo` object for testing purposes only.
|
||||
*/
|
||||
const makeVersionOutput = (version) => ({
|
||||
const makeVersionInfo = (version) => ({
|
||||
version,
|
||||
});
|
||||
exports.makeVersionOutput = makeVersionOutput;
|
||||
exports.makeVersionInfo = makeVersionInfo;
|
||||
function mockCodeQLVersion(version) {
|
||||
return {
|
||||
async getVersion() {
|
||||
return (0, exports.makeVersionOutput)(version);
|
||||
return (0, exports.makeVersionInfo)(version);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
2
lib/trap-caching.test.js
generated
2
lib/trap-caching.test.js
generated
|
|
@ -40,7 +40,7 @@ const util = __importStar(require("./util"));
|
|||
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||
const stubCodeql = (0, codeql_1.setCodeQL)({
|
||||
async getVersion() {
|
||||
return (0, testing_utils_1.makeVersionOutput)("2.10.3");
|
||||
return (0, testing_utils_1.makeVersionInfo)("2.10.3");
|
||||
},
|
||||
async betterResolveLanguages() {
|
||||
return {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -21,7 +21,7 @@ import {
|
|||
setupTests,
|
||||
setupActionsVars,
|
||||
createFeatures,
|
||||
makeVersionOutput,
|
||||
makeVersionInfo,
|
||||
} from "./testing-utils";
|
||||
import * as uploadLib from "./upload-lib";
|
||||
import * as util from "./util";
|
||||
|
|
@ -262,7 +262,7 @@ test("status report fields and search path setting", async (t) => {
|
|||
|
||||
function mockCodeQL(): Partial<CodeQL> {
|
||||
return {
|
||||
getVersion: async () => makeVersionOutput("1.0.0"),
|
||||
getVersion: async () => makeVersionInfo("1.0.0"),
|
||||
databaseRunQueries: sinon.spy(),
|
||||
databaseInterpretResults: async () => "",
|
||||
databasePrintBaseline: async () => "",
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {
|
|||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
mockBundleDownloadApi,
|
||||
makeVersionOutput,
|
||||
makeVersionInfo,
|
||||
} from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
import { initializeEnvironment } from "./util";
|
||||
|
|
@ -564,9 +564,7 @@ test("databaseInitCluster() without injected codescanning config", async (t) =>
|
|||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(makeVersionOutput("2.10.5"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.10.5"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -611,7 +609,7 @@ const injectedConfigMacro = test.macro({
|
|||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(
|
||||
makeVersionOutput(
|
||||
makeVersionInfo(
|
||||
featureConfig[Feature.CliConfigFileEnabled].minimumVersion ||
|
||||
"1.0.0",
|
||||
),
|
||||
|
|
@ -837,7 +835,7 @@ test("does not pass a code scanning config or qlconfig file to the CLI when CLI
|
|||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
// stubbed version doesn't matter. It just needs to be valid semver.
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("0.0.0"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("0.0.0"));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -869,7 +867,7 @@ test("passes a code scanning config AND qlconfig to the CLI when CLI config pass
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
.resolves(makeVersionInfo(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -899,9 +897,7 @@ test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI confi
|
|||
await util.withTmpDir(async (tempDir) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(makeVersionOutput("2.12.2"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.12.2"));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -936,7 +932,7 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
.resolves(makeVersionInfo(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -958,7 +954,7 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
|
|||
test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.3"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.11.3"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -984,7 +980,7 @@ test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3"
|
|||
test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.2"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.11.2"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -1047,7 +1043,7 @@ for (const {
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(makeVersionOutput(codeqlVersion));
|
||||
.resolves(makeVersionInfo(codeqlVersion));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -1090,7 +1086,7 @@ test("database finalize recognises JavaScript no code found error on CodeQL 2.11
|
|||
2020-09-07T17:39:53.9251124Z [2020-09-07 17:39:53] [ERROR] Spawned process exited abnormally (code 255; tried to run: [/opt/hostedtoolcache/CodeQL/0.0.0-20200630/x64/codeql/javascript/tools/autobuild.sh])`,
|
||||
);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1107,7 +1103,7 @@ test("database finalize recognises JavaScript no code found error on CodeQL 2.11
|
|||
test("database finalize overrides no code found error on CodeQL 2.11.6", async (t) => {
|
||||
stubToolRunnerConstructor(32);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1127,7 +1123,7 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",
|
|||
"https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build.";
|
||||
stubToolRunnerConstructor(32, cliMessage);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1152,7 +1148,7 @@ test("runTool summarizes several fatal errors", async (t) => {
|
|||
`${heapError}\n${datasetImportError}.`;
|
||||
stubToolRunnerConstructor(32, cliStderr);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ export interface CodeQL {
|
|||
/**
|
||||
* Get a string containing the semver version of the CodeQL executable.
|
||||
*/
|
||||
getVersion(): Promise<VersionOutput>;
|
||||
getVersion(): Promise<VersionInfo>;
|
||||
/**
|
||||
* Print version information about CodeQL.
|
||||
*/
|
||||
|
|
@ -212,7 +212,7 @@ export interface CodeQL {
|
|||
resolveExtractor(language: Language): Promise<string>;
|
||||
}
|
||||
|
||||
export interface VersionOutput {
|
||||
export interface VersionInfo {
|
||||
version: string;
|
||||
features?: { [name: string]: boolean };
|
||||
}
|
||||
|
|
@ -540,7 +540,7 @@ export async function getCodeQLForCmd(
|
|||
if (result === undefined) {
|
||||
const output = await runTool(cmd, ["version", "--format=json"]);
|
||||
try {
|
||||
result = JSON.parse(output) as VersionOutput;
|
||||
result = JSON.parse(output) as VersionInfo;
|
||||
} catch (err) {
|
||||
throw Error(
|
||||
`Invalid JSON output from \`version --format=json\`: ${output}`,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
setupTests,
|
||||
createFeatures,
|
||||
mockLanguagesInRepo as mockLanguagesInRepo,
|
||||
makeVersionOutput,
|
||||
makeVersionInfo,
|
||||
} from "./testing-utils";
|
||||
import {
|
||||
GitHubVariant,
|
||||
|
|
@ -2353,7 +2353,7 @@ test("downloadPacks-with-registries", async (t) => {
|
|||
|
||||
const codeQL = setCodeQL({
|
||||
packDownload: packDownloadStub,
|
||||
getVersion: () => Promise.resolve(makeVersionOutput("2.10.5")),
|
||||
getVersion: () => Promise.resolve(makeVersionInfo("2.10.5")),
|
||||
});
|
||||
|
||||
// packs are supplied for go, java, and python
|
||||
|
|
@ -2411,7 +2411,7 @@ test("downloadPacks-with-registries fails with invalid registries block", async
|
|||
]);
|
||||
|
||||
const codeQL = setCodeQL({
|
||||
getVersion: () => Promise.resolve(makeVersionOutput("2.10.4")),
|
||||
getVersion: () => Promise.resolve(makeVersionInfo("2.10.4")),
|
||||
});
|
||||
await t.throwsAsync(
|
||||
async () => {
|
||||
|
|
|
|||
|
|
@ -209,16 +209,16 @@ export function mockLanguagesInRepo(languages: string[]) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs a `VersionOutput` object for testing purposes only.
|
||||
* Constructs a `VersionInfo` object for testing purposes only.
|
||||
*/
|
||||
export const makeVersionOutput = (version: string): CodeQL.VersionOutput => ({
|
||||
export const makeVersionInfo = (version: string): CodeQL.VersionInfo => ({
|
||||
version,
|
||||
});
|
||||
|
||||
export function mockCodeQLVersion(version: string) {
|
||||
return {
|
||||
async getVersion() {
|
||||
return makeVersionOutput(version);
|
||||
return makeVersionInfo(version);
|
||||
},
|
||||
} as CodeQL.CodeQL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { Config } from "./config-utils";
|
|||
import { Language } from "./languages";
|
||||
import {
|
||||
getRecordingLogger,
|
||||
makeVersionOutput,
|
||||
makeVersionInfo,
|
||||
setupTests,
|
||||
} from "./testing-utils";
|
||||
import {
|
||||
|
|
@ -30,7 +30,7 @@ setupTests(test);
|
|||
|
||||
const stubCodeql = setCodeQL({
|
||||
async getVersion() {
|
||||
return makeVersionOutput("2.10.3");
|
||||
return makeVersionInfo("2.10.3");
|
||||
},
|
||||
async betterResolveLanguages() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import getFolderSize from "get-folder-size";
|
|||
import * as semver from "semver";
|
||||
|
||||
import * as apiCompatibility from "./api-compatibility.json";
|
||||
import type { CodeQL, VersionOutput } from "./codeql";
|
||||
import type { CodeQL, VersionInfo } from "./codeql";
|
||||
import type { Config, Pack } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Language } from "./languages";
|
||||
|
|
@ -576,16 +576,16 @@ export function isHTTPError(arg: any): arg is HTTPError {
|
|||
return arg?.status !== undefined && Number.isInteger(arg.status);
|
||||
}
|
||||
|
||||
let cachedCodeQlVersion: undefined | VersionOutput = undefined;
|
||||
let cachedCodeQlVersion: undefined | VersionInfo = undefined;
|
||||
|
||||
export function cacheCodeQlVersion(version: VersionOutput): void {
|
||||
export function cacheCodeQlVersion(version: VersionInfo): void {
|
||||
if (cachedCodeQlVersion !== undefined) {
|
||||
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||
}
|
||||
cachedCodeQlVersion = version;
|
||||
}
|
||||
|
||||
export function getCachedCodeQlVersion(): undefined | VersionOutput {
|
||||
export function getCachedCodeQlVersion(): undefined | VersionInfo {
|
||||
return cachedCodeQlVersion;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue