Add external git repositories to search path for custom queries
This commit is contained in:
parent
1fa35632f2
commit
578f9fc99e
15 changed files with 244 additions and 100 deletions
|
|
@ -13,11 +13,25 @@ import * as util from "./util";
|
|||
setupTests(test);
|
||||
|
||||
// Checks that the duration fields are populated for the correct language
|
||||
// and correct case of builtin or custom.
|
||||
test("status report fields", async (t) => {
|
||||
// and correct case of builtin or custom. Also checks the correct search
|
||||
// paths are set in the database analyze invocation.
|
||||
test("status report fields and search path setting", async (t) => {
|
||||
let searchPathsUsed: string[] = [];
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
setCodeQL({
|
||||
databaseAnalyze: async () => undefined,
|
||||
databaseAnalyze: async (
|
||||
_,
|
||||
sarifFile: string,
|
||||
searchPath: string | undefined
|
||||
) => {
|
||||
fs.writeFileSync(
|
||||
sarifFile,
|
||||
JSON.stringify({
|
||||
runs: [],
|
||||
})
|
||||
);
|
||||
searchPathsUsed.push(searchPath!);
|
||||
},
|
||||
});
|
||||
|
||||
const memoryFlag = "";
|
||||
|
|
@ -25,6 +39,7 @@ test("status report fields", async (t) => {
|
|||
const threadsFlag = "";
|
||||
|
||||
for (const language of Object.values(Language)) {
|
||||
searchPathsUsed = [];
|
||||
const config: Config = {
|
||||
languages: [language],
|
||||
queries: {},
|
||||
|
|
@ -61,7 +76,16 @@ test("status report fields", async (t) => {
|
|||
|
||||
config.queries[language] = {
|
||||
builtin: [],
|
||||
custom: ["foo.ql"],
|
||||
custom: [
|
||||
{
|
||||
queries: ["foo.ql"],
|
||||
searchPath: "/1",
|
||||
},
|
||||
{
|
||||
queries: ["bar.ql"],
|
||||
searchPath: "/2",
|
||||
},
|
||||
],
|
||||
};
|
||||
const customStatusReport = await runQueries(
|
||||
tmpDir,
|
||||
|
|
@ -75,6 +99,7 @@ test("status report fields", async (t) => {
|
|||
t.true(
|
||||
`analyze_custom_queries_${language}_duration_ms` in customStatusReport
|
||||
);
|
||||
t.deepEqual(searchPathsUsed, [undefined, "/1", "/2"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue