Replace analyze with run-queries and interpret-results
This commit is contained in:
parent
c09500540c
commit
2cc885d66e
9 changed files with 180 additions and 160 deletions
15
lib/analyze.test.js
generated
15
lib/analyze.test.js
generated
|
|
@ -41,7 +41,10 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
const threadsFlag = "";
|
||||
for (const language of Object.values(languages_1.Language)) {
|
||||
codeql_1.setCodeQL({
|
||||
databaseAnalyze: async (_, sarifFile, searchPath) => {
|
||||
databaseRunQueries: async (_db, searchPath) => {
|
||||
searchPathsUsed.push(searchPath);
|
||||
},
|
||||
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
|
||||
fs.writeFileSync(sarifFile, JSON.stringify({
|
||||
runs: [
|
||||
// variant 1 uses ruleId
|
||||
|
|
@ -71,7 +74,6 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
{},
|
||||
],
|
||||
}));
|
||||
searchPathsUsed.push(searchPath);
|
||||
return "";
|
||||
},
|
||||
});
|
||||
|
|
@ -98,8 +100,9 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
custom: [],
|
||||
};
|
||||
const builtinStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
||||
t.deepEqual(Object.keys(builtinStatusReport).length, 1);
|
||||
t.deepEqual(Object.keys(builtinStatusReport).length, 2);
|
||||
t.true(`analyze_builtin_queries_${language}_duration_ms` in builtinStatusReport);
|
||||
t.true(`interpret_results_${language}_duration_ms` in builtinStatusReport);
|
||||
config.queries[language] = {
|
||||
builtin: [],
|
||||
custom: [
|
||||
|
|
@ -114,8 +117,9 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
],
|
||||
};
|
||||
const customStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
||||
t.deepEqual(Object.keys(customStatusReport).length, 1);
|
||||
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
||||
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
||||
t.true(`interpret_results_${language}_duration_ms` in customStatusReport);
|
||||
t.deepEqual(searchPathsUsed, [undefined, "/1", "/2"]);
|
||||
}
|
||||
verifyLineCounts(tmpDir);
|
||||
|
|
@ -123,8 +127,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
function verifyLineCounts(tmpDir) {
|
||||
// eslint-disable-next-line github/array-foreach
|
||||
Object.keys(languages_1.Language).forEach((lang, i) => {
|
||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}-builtin.sarif`), i + 1);
|
||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}-custom.sarif`), i + 1);
|
||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}.sarif`), i + 1);
|
||||
});
|
||||
}
|
||||
function verifyLineCountForFile(lang, filePath, lineCount) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue