2020-08-24 14:53:09 +03:00
|
|
|
"use strict";
|
2021-07-27 19:59:59 +03:00
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
2023-01-18 23:00:33 +03:00
|
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
|
|
}
|
|
|
|
Object.defineProperty(o, k2, desc);
|
2021-07-27 19:59:59 +03:00
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
o[k2] = m[k];
|
|
|
|
}));
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
}) : function(o, v) {
|
|
|
|
o["default"] = v;
|
|
|
|
});
|
2020-08-24 14:53:09 +03:00
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
2021-07-27 19:59:59 +03:00
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
__setModuleDefault(result, mod);
|
2020-08-24 14:53:09 +03:00
|
|
|
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-08-24 14:53:09 +03:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const fs = __importStar(require("fs"));
|
|
|
|
const path = __importStar(require("path"));
|
2020-09-29 16:43:37 +03:00
|
|
|
const ava_1 = __importDefault(require("ava"));
|
2022-08-11 01:42:45 +03:00
|
|
|
const configUtils = __importStar(require("./config-utils"));
|
2020-10-01 13:03:30 +03:00
|
|
|
const languages_1 = require("./languages");
|
2020-08-24 14:53:09 +03:00
|
|
|
const testing_utils_1 = require("./testing-utils");
|
2020-10-01 13:03:30 +03:00
|
|
|
const tracer_config_1 = require("./tracer-config");
|
|
|
|
const util = __importStar(require("./util"));
|
2021-09-10 23:53:13 +03:00
|
|
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
2020-08-24 14:53:09 +03:00
|
|
|
function getTestConfig(tmpDir) {
|
|
|
|
return {
|
|
|
|
languages: [languages_1.Language.java],
|
|
|
|
queries: {},
|
|
|
|
pathsIgnore: [],
|
|
|
|
paths: [],
|
|
|
|
originalUserInput: {},
|
|
|
|
tempDir: tmpDir,
|
2020-09-14 12:44:43 +03:00
|
|
|
codeQLCmd: "",
|
2021-02-15 12:29:10 +03:00
|
|
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
2021-05-17 12:35:09 +03:00
|
|
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
2021-06-03 19:32:44 +03:00
|
|
|
packs: {},
|
2021-10-28 16:15:22 +03:00
|
|
|
debugMode: false,
|
2022-01-07 16:11:51 +03:00
|
|
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
|
|
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
2022-08-11 01:42:45 +03:00
|
|
|
augmentationProperties: configUtils.defaultAugmentationProperties,
|
2022-08-02 19:52:22 +03:00
|
|
|
trapCaches: {},
|
2022-08-15 16:44:43 +03:00
|
|
|
trapCacheDownloadTime: 0,
|
2020-08-24 14:53:09 +03:00
|
|
|
};
|
|
|
|
}
|
2021-09-10 23:53:13 +03:00
|
|
|
(0, ava_1.default)("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
2020-08-24 14:53:09 +03:00
|
|
|
await util.withTmpDir(async (tmpDir) => {
|
|
|
|
const config = getTestConfig(tmpDir);
|
|
|
|
// No traced languages
|
|
|
|
config.languages = [languages_1.Language.javascript, languages_1.Language.python];
|
2023-03-28 20:38:33 +03:00
|
|
|
t.deepEqual(await (0, tracer_config_1.getCombinedTracerConfig)(config), undefined);
|
2020-08-24 14:53:09 +03:00
|
|
|
});
|
|
|
|
});
|
2023-03-28 20:38:33 +03:00
|
|
|
(0, ava_1.default)("getCombinedTracerConfig - with start-tracing.json environment file", async (t) => {
|
2020-08-24 14:53:09 +03:00
|
|
|
await util.withTmpDir(async (tmpDir) => {
|
|
|
|
const config = getTestConfig(tmpDir);
|
2021-01-12 14:29:30 +03:00
|
|
|
const bundlePath = path.join(tmpDir, "bundle");
|
|
|
|
const codeqlPlatform = process.platform === "win32"
|
|
|
|
? "win64"
|
|
|
|
: process.platform === "darwin"
|
|
|
|
? "osx64"
|
|
|
|
: "linux64";
|
2023-03-28 20:38:33 +03:00
|
|
|
const startTracingEnv = {
|
2020-09-14 12:44:43 +03:00
|
|
|
foo: "bar",
|
2021-01-12 14:29:30 +03:00
|
|
|
CODEQL_DIST: bundlePath,
|
|
|
|
CODEQL_PLATFORM: codeqlPlatform,
|
2020-08-28 16:46:23 +03:00
|
|
|
};
|
2023-03-28 20:38:33 +03:00
|
|
|
const tracingEnvironmentDir = path.join(config.dbLocation, "temp", "tracingEnvironment");
|
|
|
|
fs.mkdirSync(tracingEnvironmentDir, { recursive: true });
|
|
|
|
const startTracingJson = path.join(tracingEnvironmentDir, "start-tracing.json");
|
|
|
|
fs.writeFileSync(startTracingJson, JSON.stringify(startTracingEnv));
|
|
|
|
const result = await (0, tracer_config_1.getCombinedTracerConfig)(config);
|
|
|
|
t.notDeepEqual(result, undefined);
|
|
|
|
const expectedEnv = startTracingEnv;
|
2021-01-12 14:29:30 +03:00
|
|
|
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");
|
|
|
|
}
|
2020-08-24 14:53:09 +03:00
|
|
|
t.deepEqual(result, {
|
2020-08-28 16:46:23 +03:00
|
|
|
env: expectedEnv,
|
2020-08-24 14:53:09 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//# sourceMappingURL=tracer-config.test.js.map
|