Exclude the temporary directory from scanning.

This commit is contained in:
Chris Gavin
2020-09-28 12:15:06 +01:00
parent 2841489ddf
commit 206e34cbb4
9 changed files with 85 additions and 16 deletions
+24 -2
View File
@@ -1,6 +1,8 @@
import test from "ava";
import * as path from "path";
import * as analysisPaths from "./analysis-paths";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";
@@ -18,7 +20,7 @@ test("emptyPaths", async (t) => {
toolCacheDir: tmpDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_EXCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
@@ -37,7 +39,7 @@ test("nonEmptyPaths", async (t) => {
toolCacheDir: tmpDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
t.is(process.env["LGTM_INDEX_EXCLUDE"], "path4\npath5");
t.is(
@@ -46,3 +48,23 @@ test("nonEmptyPaths", async (t) => {
);
});
});
test("exclude temp dir", async (t) => {
return await util.withTmpDir(async (toolCacheDir) => {
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
const config = {
languages: [],
queries: {},
pathsIgnore: [],
paths: [],
originalUserInput: {},
tempDir,
toolCacheDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_EXCLUDE"], tempDir);
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
});
});