Skip to content

Commit 10b4c15

Browse files
committed
Fail fast if codeql CLI is missing from the workspace
In order to run our cli-integration tests, we're required to have a local copy of the codeql CLI repo. We can then run the tests by running the `Launch Integration Tests - With CLI` task from inside VS Code. (See CONTRIBUTING.md for details.) If we don't have the CLI repo cloned locally or we're not pointing to it in `launch.json`, we don't get a clear indication of what the problem is. The tests will still attempt to run. Let's fail fast instead and add an actionable error message to the output.
1 parent c84b858 commit 10b4c15

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extensions/ql-vscode/src/vscode-tests/cli-integration/global.helper.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function(mocha: Mocha) {
7575
}
7676
);
7777

78-
// ensure etension is cleaned up.
78+
// ensure extension is cleaned up.
7979
(mocha.options as any).globalTeardown.push(
8080
async () => {
8181
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
@@ -93,6 +93,21 @@ export default function(mocha: Mocha) {
9393
removeStorage?.();
9494
}
9595
);
96+
97+
// check that the codeql folder is found in the workspace
98+
(mocha.options as any).globalSetup.push(
99+
async () => {
100+
const folders = workspace.workspaceFolders;
101+
if (!folders) {
102+
fail('\n\n\nNo workspace folders found.\nYou will need a local copy of the codeql repo.\nMake sure you specify the path to it in launch.json.\nIt should be something along the lines of "${workspaceRoot}/../codeql" depending on where you have your local copy of the codeql repo.\n\n\n');
103+
} else {
104+
const codeqlFolder = folders.find(folder => folder.name === 'codeql');
105+
if (!codeqlFolder) {
106+
fail('\n\n\nNo workspace folders found.\nYou will need a local copy of the codeql repo.\nMake sure you specify the path to it in launch.json.\nIt should be something along the lines of "${workspaceRoot}/../codeql" depending on where you have your local copy of the codeql repo.\n\n\n');
107+
}
108+
}
109+
}
110+
);
96111
}
97112

98113
export async function cleanDatabases(databaseManager: DatabaseManager) {

0 commit comments

Comments
 (0)