2020-09-10 20:02:33 +03:00
|
|
|
"use strict";
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
result["default"] = mod;
|
|
|
|
return result;
|
|
|
|
};
|
2020-09-29 16:43:37 +03:00
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
2020-09-10 20:02:33 +03:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const fs = __importStar(require("fs"));
|
2020-09-29 16:43:37 +03:00
|
|
|
const ava_1 = __importDefault(require("ava"));
|
|
|
|
const analyze_1 = require("./analyze");
|
|
|
|
const codeql_1 = require("./codeql");
|
2020-10-01 13:03:30 +03:00
|
|
|
const languages_1 = require("./languages");
|
|
|
|
const logging_1 = require("./logging");
|
2020-09-10 20:02:33 +03:00
|
|
|
const testing_utils_1 = require("./testing-utils");
|
2020-10-01 13:03:30 +03:00
|
|
|
const util = __importStar(require("./util"));
|
2020-09-10 20:02:33 +03:00
|
|
|
testing_utils_1.setupTests(ava_1.default);
|
|
|
|
// Checks that the duration fields are populated for the correct language
|
|
|
|
// and correct case of builtin or custom.
|
2020-09-18 11:52:44 +03:00
|
|
|
ava_1.default("status report fields", async (t) => {
|
2020-09-10 20:02:33 +03:00
|
|
|
return await util.withTmpDir(async (tmpDir) => {
|
|
|
|
codeql_1.setCodeQL({
|
2020-09-18 11:52:44 +03:00
|
|
|
databaseAnalyze: async () => undefined,
|
2020-09-10 20:02:33 +03:00
|
|
|
});
|
2020-09-18 11:52:44 +03:00
|
|
|
const memoryFlag = "";
|
|
|
|
const addSnippetsFlag = "";
|
|
|
|
const threadsFlag = "";
|
2020-09-10 20:02:33 +03:00
|
|
|
for (const language of Object.values(languages_1.Language)) {
|
|
|
|
const config = {
|
|
|
|
languages: [language],
|
|
|
|
queries: {},
|
|
|
|
pathsIgnore: [],
|
|
|
|
paths: [],
|
|
|
|
originalUserInput: {},
|
|
|
|
tempDir: tmpDir,
|
|
|
|
toolCacheDir: tmpDir,
|
2020-09-18 11:52:44 +03:00
|
|
|
codeQLCmd: "",
|
2021-02-15 12:29:10 +03:00
|
|
|
gitHubVersion: {
|
|
|
|
type: util.GitHubVariant.DOTCOM,
|
|
|
|
},
|
2020-09-10 20:02:33 +03:00
|
|
|
};
|
2020-09-18 11:52:44 +03:00
|
|
|
fs.mkdirSync(util.getCodeQLDatabasePath(config.tempDir, language), {
|
|
|
|
recursive: true,
|
|
|
|
});
|
2020-09-10 20:02:33 +03:00
|
|
|
config.queries[language] = {
|
2020-09-18 11:52:44 +03:00
|
|
|
builtin: ["foo.ql"],
|
2020-09-10 20:02:33 +03:00
|
|
|
custom: [],
|
|
|
|
};
|
2020-09-18 11:52:44 +03:00
|
|
|
const builtinStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logging_1.getRunnerLogger(true));
|
2020-09-10 20:02:33 +03:00
|
|
|
t.deepEqual(Object.keys(builtinStatusReport).length, 1);
|
|
|
|
t.true(`analyze_builtin_queries_${language}_duration_ms` in builtinStatusReport);
|
|
|
|
config.queries[language] = {
|
|
|
|
builtin: [],
|
2020-09-18 11:52:44 +03:00
|
|
|
custom: ["foo.ql"],
|
2020-09-10 20:02:33 +03:00
|
|
|
};
|
2020-09-18 11:52:44 +03:00
|
|
|
const customStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logging_1.getRunnerLogger(true));
|
2020-09-10 20:02:33 +03:00
|
|
|
t.deepEqual(Object.keys(customStatusReport).length, 1);
|
|
|
|
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//# sourceMappingURL=analyze.test.js.map
|