Add tests of CODEQL_RUNNER env var
This commit is contained in:
parent
c796788c33
commit
2f9814894f
6 changed files with 59 additions and 4 deletions
|
|
@ -302,6 +302,7 @@ test("getCombinedTracerConfig - return undefined when no languages are traced la
|
|||
async getTracerEnv() {
|
||||
return {
|
||||
ODASA_TRACER_CONFIGURATION: "abc",
|
||||
CODEQL_DIST: "/",
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
|
|
@ -318,21 +319,35 @@ test("getCombinedTracerConfig - valid spec file", async (t) => {
|
|||
const spec = path.join(tmpDir, "spec");
|
||||
fs.writeFileSync(spec, "foo.log\n2\nabc\ndef");
|
||||
|
||||
const bundlePath = path.join(tmpDir, "bundle");
|
||||
const codeqlPlatform =
|
||||
process.platform === "win32"
|
||||
? "win64"
|
||||
: process.platform === "darwin"
|
||||
? "osx64"
|
||||
: "linux64";
|
||||
|
||||
const codeQL = setCodeQL({
|
||||
async getTracerEnv() {
|
||||
return {
|
||||
ODASA_TRACER_CONFIGURATION: spec,
|
||||
CODEQL_DIST: bundlePath,
|
||||
CODEQL_PLATFORM: codeqlPlatform,
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const result = await getCombinedTracerConfig(config, codeQL);
|
||||
t.notDeepEqual(result, undefined);
|
||||
|
||||
const expectedEnv = {
|
||||
foo: "bar",
|
||||
CODEQL_DIST: bundlePath,
|
||||
CODEQL_PLATFORM: codeqlPlatform,
|
||||
ODASA_TRACER_CONFIGURATION: result!.spec,
|
||||
};
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
expectedEnv["DYLD_INSERT_LIBRARIES"] = path.join(
|
||||
path.dirname(codeQL.getPath()),
|
||||
|
|
@ -349,6 +364,23 @@ test("getCombinedTracerConfig - valid spec file", async (t) => {
|
|||
);
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
expectedEnv["CODEQL_RUNNER"] = path.join(
|
||||
bundlePath,
|
||||
"tools/win64/runner.exe"
|
||||
);
|
||||
} else if (process.platform === "darwin") {
|
||||
expectedEnv["CODEQL_RUNNER"] = path.join(
|
||||
bundlePath,
|
||||
"tools/osx64/runner"
|
||||
);
|
||||
} else {
|
||||
expectedEnv["CODEQL_RUNNER"] = path.join(
|
||||
bundlePath,
|
||||
"tools/linux64/runner"
|
||||
);
|
||||
}
|
||||
|
||||
t.deepEqual(result, {
|
||||
spec: path.join(tmpDir, "compound-spec"),
|
||||
env: expectedEnv,
|
||||
|
|
|
|||
|
|
@ -189,11 +189,12 @@ export async function getCombinedTracerConfig(
|
|||
// on order to trace when System Integrity Protection is enabled.
|
||||
// The exectuable also exists and works for other platforms so we output this env
|
||||
// var with a path to the runner regardless so it's always available.
|
||||
const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner";
|
||||
mainTracerConfig.env["CODEQL_RUNNER"] = path.join(
|
||||
mainTracerConfig.env["CODEQL_DIST"],
|
||||
"tools",
|
||||
mainTracerConfig.env["CODEQL_PLATFORM"],
|
||||
"runner"
|
||||
runnerExeName
|
||||
);
|
||||
|
||||
return mainTracerConfig;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue