Files
vscode-codeql/extensions/ql-vscode/test/vscode-tests/cli.ts
Andrew Eisenberg 256b806cd4 Remove skipIfTrue
Also, add a comment to the vscode settings file and describe how to use
it.
2023-02-14 14:47:39 -08:00

45 lines
1.6 KiB
TypeScript

import { workspace } from "vscode";
/**
* Heuristically determines if the codeql libraries are installed in this
* workspace. Looks for the existance of a folder whose path ends in `/codeql`
*/
function hasCodeQL() {
const folders = workspace.workspaceFolders;
return !!folders?.some((folder) => folder.uri.path.endsWith("/codeql"));
}
// describeWithCodeQL will be equal to describe if the CodeQL libraries are
// available in this workspace. Otherwise, it will skip the tests.
export function describeWithCodeQL() {
if (!hasCodeQL()) {
console.log(
[
"The CodeQL libraries are not available as a folder in this workspace.",
"To fix in CI: checkout the github/codeql repository and set the 'TEST_CODEQL_PATH' environment variable to the checked out directory.",
"To fix when running from vs code, see the comment in the launch.json file in the 'Launch Integration Tests - With CLI' section.",
].join("\n\n"),
);
return describe.skip;
}
return describe;
}
// itWithCodeQL will be equal to it if the CodeQL libraries are
// available in this workspace. Otherwise, it will skip the tests.
export function itWithCodeQL() {
if (!hasCodeQL()) {
console.log(
[
"The CodeQL libraries are not available as a folder in this workspace.",
"To fix in CI: checkout the github/codeql repository and set the 'TEST_CODEQL_PATH' environment variable to the checked out directory.",
"To fix when running from vs code, see the comment in the launch.json file in the 'Launch Integration Tests - With CLI' section.",
].join("\n\n"),
);
return it.skip;
}
return it;
}