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.
This commit is contained in:
Elena Tanasoiu
2022-06-22 19:30:53 +01:00
parent c84b858205
commit 10b4c15053

View File

@@ -75,7 +75,7 @@ export default function(mocha: Mocha) {
}
);
// ensure etension is cleaned up.
// ensure extension is cleaned up.
(mocha.options as any).globalTeardown.push(
async () => {
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
@@ -93,6 +93,21 @@ export default function(mocha: Mocha) {
removeStorage?.();
}
);
// check that the codeql folder is found in the workspace
(mocha.options as any).globalSetup.push(
async () => {
const folders = workspace.workspaceFolders;
if (!folders) {
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');
} else {
const codeqlFolder = folders.find(folder => folder.name === 'codeql');
if (!codeqlFolder) {
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');
}
}
}
);
}
export async function cleanDatabases(databaseManager: DatabaseManager) {