Re-enable the queries cli test

* Requires that QL_PATH environment variable is set and points to a
  checkout of github/codeql
* Adds the `quiet` flag to the cli. When set, this flag will prevent
  some modal dialogs from disrupting the flow. Currently, we only ensure
  that the upgrades dialog is avoided.
* Update the main.yml workflow to checkout the codeql repo
This commit is contained in:
Andrew Eisenberg
2020-12-05 09:02:42 -08:00
parent b5e708796d
commit 69ca0f55ba
9 changed files with 45 additions and 14 deletions

View File

@@ -124,12 +124,11 @@ jobs:
version: ['v2.2.6', 'v2.3.3', 'v2.4.0']
env:
CLI_VERSION: ${{ matrix.version }}
QL_PATH: '${{ github.workspace }}/codeql'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
@@ -147,6 +146,12 @@ jobs:
npm run build
shell: bash
- name: Checkout QL
uses: actions/checkout@v2
with:
repository: github/codeql
path: codeql
- name: Run CLI tests (Linux)
working-directory: extensions/ql-vscode
if: matrix.os == 'ubuntu-latest'

2
.vscode/launch.json vendored
View File

@@ -86,7 +86,7 @@
"args": [
"--extensionDevelopmentPath=${workspaceRoot}/extensions/ql-vscode",
"--extensionTestsPath=${workspaceRoot}/extensions/ql-vscode/out/vscode-tests/cli-integration/index",
"${workspaceRoot}/extensions/ql-vscode/test/data"
"${workspaceRoot}/extensions/ql-vscode/src/vscode-tests/cli-integration/data",
],
"stopOnEntry": false,
"sourceMaps": true,

View File

@@ -144,10 +144,15 @@ export class CodeQLCliServer implements Disposable {
/** Path to current codeQL executable, or undefined if not running yet. */
codeQlPath: string | undefined;
/**
* When set to true, ignore some modal popups and assume user has clicked "yes".
*/
public quiet = false;
constructor(
private distributionProvider: DistributionProvider,
private cliConfig: CliConfig,
private logger: Logger,
private logger: Logger
) {
this.commandQueue = [];
this.commandInProcess = false;

View File

@@ -62,7 +62,12 @@ export class QueryServerClient extends DisposableObject {
withProgressReporting: WithProgressReporting;
public activeQueryName: string | undefined;
constructor(readonly config: QueryServerConfig, readonly cliServer: cli.CodeQLCliServer, readonly opts: ServerOpts, withProgressReporting: WithProgressReporting) {
constructor(
readonly config: QueryServerConfig,
readonly cliServer: cli.CodeQLCliServer,
readonly opts: ServerOpts,
withProgressReporting: WithProgressReporting
) {
super();
// When the query server configuration changes, restart the query server.
if (config.onDidChangeConfiguration !== undefined) {

View File

@@ -82,6 +82,13 @@ async function checkAndConfirmDatabaseUpgrade(
}
logger.log(descriptionMessage);
// If the quiet flag is set, do the upgrade without a popup.
if (qs.cliServer.quiet) {
return params;
}
// Ask the user to confirm the upgrade.
const showLogItem: vscode.MessageItem = { title: 'No, Show Changes', isCloseAffordance: true };

View File

@@ -1,2 +1,3 @@
name: integration-test-queries-javascript
version: 0.0.0
libraryPathDependencies: codeql-javascript

View File

@@ -44,11 +44,12 @@ export default function(mocha: /*Mocha*/ any) {
}
},
// Set the CLI version here before activation to ensure we don't accidentally try to download a cli
async () => {
// Set the CLI version here before activation to ensure we don't accidentally try to download a cli
await workspace.getConfiguration().update('codeQL.cli.executablePath', process.env.CLI_PATH, ConfigurationTarget.Global);
},
// Create the temp directory to be used as extension local storage.
() => {
const dir = tmp.dirSync();
storagePath = fs.realpathSync(dir.name);
@@ -61,7 +62,10 @@ export default function(mocha: /*Mocha*/ any) {
mocha.globalTeardown(() => {
removeStorage?.();
});
mocha.globalTeardown([
// ensure temp directory is cleaned up.
() => {
removeStorage?.();
}
]);
}

View File

@@ -18,9 +18,7 @@ import { QueryServerClient } from '../../queryserver-client';
/**
* Integration tests for queries
*/
// TODO: Not currently able to run this because we do not have access to the javascript qlpack.
// Need to download ql libraries separately.
xdescribe('Queries', function() {
describe.only('Queries', function() {
this.timeout(20000);
let dbItem: DatabaseItem;
@@ -40,6 +38,7 @@ xdescribe('Queries', function() {
databaseManager = extension.databaseManager;
cli = extension.cliServer;
qs = extension.qs;
cli.quiet = true;
} else {
throw new Error('Extension not initialized. Make sure cli is downloaded and installed properly.');
}

View File

@@ -88,13 +88,15 @@ async function main() {
console.log(`Running integration tests in these directories: ${dirs}`);
for (const dir of dirs) {
const launchArgs = getLaunchArgs(dir as TestDir);
console.log(`Next integration test dir: ${dir}`);
console.log(`Launch args: ${launchArgs}`);
await runTestsWithRetryOnSegfault({
version: VSCODE_VERSION,
vscodeExecutablePath,
extensionDevelopmentPath,
extensionTestsPath: path.resolve(__dirname, dir, 'index'),
launchArgs: getLaunchArgs(dir as TestDir)
launchArgs
}, 3);
}
} catch (err) {
@@ -120,7 +122,10 @@ function getLaunchArgs(dir: TestDir) {
];
case TestDir.CliIntegration:
break;
return [
path.resolve(__dirname, '../../test/data'),
process.env.QL_PATH!
];
default:
assertNever(dir);