From 044bc30d969cf61ebbb4a91c29b7e0946c3f896c Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Wed, 20 Jan 2021 09:14:01 -0800 Subject: [PATCH] Clarify how to run CLI tests locally Also, remove an errant `only`, which was preventing some tests from running. --- .vscode/launch.json | 3 +++ .../src/vscode-tests/cli-integration/run-cli.test.ts | 2 +- extensions/ql-vscode/src/vscode-tests/ensureCli.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e25dd54ea..a13449b5f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -89,6 +89,9 @@ "--extensionDevelopmentPath=${workspaceRoot}/extensions/ql-vscode", "--extensionTestsPath=${workspaceRoot}/extensions/ql-vscode/out/vscode-tests/cli-integration/index", "${workspaceRoot}/extensions/ql-vscode/src/vscode-tests/cli-integration/data", + // Add a path to a checked out instance of the codeql repository so the libraries are + // available in the workspace for the tests. + // "${workspaceRoot}/../codeql" ], "stopOnEntry": false, "sourceMaps": true, diff --git a/extensions/ql-vscode/src/vscode-tests/cli-integration/run-cli.test.ts b/extensions/ql-vscode/src/vscode-tests/cli-integration/run-cli.test.ts index cf0c7ff66..94132c5dc 100644 --- a/extensions/ql-vscode/src/vscode-tests/cli-integration/run-cli.test.ts +++ b/extensions/ql-vscode/src/vscode-tests/cli-integration/run-cli.test.ts @@ -40,7 +40,7 @@ describe('Use cli', function() { ]); }); - it.only('should resolve query packs', async function() { + it('should resolve query packs', async function() { skipIfNoCodeQL(this); const qlpacks = await cli.resolveQlpacks(getOnDiskWorkspaceFolders()); // should have a bunch of qlpacks. just check that a few known ones exist diff --git a/extensions/ql-vscode/src/vscode-tests/ensureCli.ts b/extensions/ql-vscode/src/vscode-tests/ensureCli.ts index ed61ff81d..532d6bc27 100644 --- a/extensions/ql-vscode/src/vscode-tests/ensureCli.ts +++ b/extensions/ql-vscode/src/vscode-tests/ensureCli.ts @@ -72,7 +72,7 @@ export async function ensureCli(useCli: boolean) { console.log('Total content size', Math.round(contentLength / _1MB), 'MB'); const archiveFile = fs.createWriteStream(downloadedFilePath); const body = assetStream.body; - await new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { let numBytesDownloaded = 0; let lastMessage = 0; body.on('data', (data) => { @@ -117,7 +117,11 @@ function hasCodeQL() { export function skipIfNoCodeQL(context: Mocha.Context) { if (!hasCodeQL()) { - console.log('The CodeQL libraries are not available as a folder in this workspace. To fix: checkout the github/codeql repository and set the TEST_CODEQL_PATH environment variable to the checked out directory.'); + 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')); context.skip(); } }