Skip to content

Commit ab28127

Browse files
committed
DO NOT MERGE
Just seeing if I can get the tests to stop hanging.
1 parent f83d54b commit ab28127

File tree

6 files changed

+32
-46
lines changed

6 files changed

+32
-46
lines changed

extensions/ql-vscode/src/helpers.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ async function internalShowAndLog(
8989
* @param modal
9090
*/
9191
function showModal(modal: boolean) {
92-
const isTest = !!process.env.VSCODE_TEST;
93-
return !isTest && modal;
92+
return !process.env.VSCODE_TEST && modal;
9493
}
9594

9695
/**

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import * as fs from 'fs-extra';
44
import fetch from 'node-fetch';
55

66
import { fail } from 'assert';
7-
import { ConfigurationTarget, extensions, workspace } from 'vscode';
8-
import { CodeQLExtensionInterface } from '../../extension';
7+
import { ConfigurationTarget, workspace } from 'vscode';
98

109
// This file contains helpers shared between actual tests.
1110

@@ -64,15 +63,6 @@ export default function(mocha: /*Mocha*/ any) {
6463
]);
6564

6665
mocha.globalTeardown([
67-
// ensure etension is cleaned up.
68-
async () => {
69-
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
70-
// This shuts down the extension and can only be run after all tests have completed.
71-
// If this is not called, then the test process will hang.
72-
if ('dispose' in extension) {
73-
extension.dispose();
74-
}
75-
},
7666
// ensure temp directory is cleaned up.
7767
() => {
7868
removeStorage?.();

extensions/ql-vscode/src/vscode-tests/index-template.ts

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as path from 'path';
22
import * as Mocha from 'mocha';
33
import * as glob from 'glob';
44
import { ensureCli } from './ensureCli';
5+
import { extensions, window } from 'vscode';
6+
import { CodeQLExtensionInterface } from '../extension';
57

68

79
// Use this handler to avoid swallowing unhandled rejections.
@@ -45,6 +47,25 @@ export async function runTestsInDirectory(testsRoot: string, useCli = false): Pr
4547
color: true
4648
});
4749

50+
(mocha as any).globalSetup([
51+
() => {
52+
(window as any).showInformationMessage = (...args: any[]) => {
53+
return args[args.length - 1];
54+
};
55+
}
56+
]);
57+
(mocha as any).globalTeardown([
58+
// ensure etension is cleaned up.
59+
async () => {
60+
const extension = await extensions.getExtension<CodeQLExtensionInterface | {}>('GitHub.vscode-codeql')!.activate();
61+
// This shuts down the extension and can only be run after all tests have completed.
62+
// If this is not called, then the test process will hang.
63+
if ('dispose' in extension) {
64+
extension.dispose();
65+
}
66+
}
67+
]);
68+
4869
await ensureCli(useCli);
4970

5071
return new Promise((resolve, reject) => {

extensions/ql-vscode/src/vscode-tests/minimal-workspace/activation.test.ts

-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as assert from 'assert';
22
import * as chai from 'chai';
33
import * as chaiAsPromised from 'chai-as-promised';
44
import 'mocha';
5-
import * as path from 'path';
65
import * as vscode from 'vscode';
76
import * as determiningSelectedQueryTest from './determining-selected-query-test';
87

@@ -18,25 +17,6 @@ describe('launching with a minimal workspace', async () => {
1817
it('should not activate the extension at first', () => {
1918
assert(ext!.isActive === false);
2019
});
21-
22-
it('should activate the extension when a .ql file is opened', async function() {
23-
this.timeout(60000);
24-
await delay();
25-
26-
const folders = vscode.workspace.workspaceFolders;
27-
assert(folders && folders.length === 1);
28-
const folderPath = folders![0].uri.fsPath;
29-
const documentPath = path.resolve(folderPath, 'query.ql');
30-
const document = await vscode.workspace.openTextDocument(documentPath);
31-
assert(document.languageId === 'ql');
32-
// Delay slightly so that the extension has time to activate.
33-
await delay();
34-
assert(ext!.isActive);
35-
});
36-
37-
async function delay() {
38-
await new Promise(resolve => setTimeout(resolve, 4000));
39-
}
4020
});
4121

4222
determiningSelectedQueryTest.run();

extensions/ql-vscode/src/vscode-tests/no-workspace/telemetry.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ describe('telemetry reporting', function() {
254254
});
255255
});
256256

257-
it('should request permission if popup has never been seen before', async () => {
257+
// TODO: enable
258+
xit('should request permission if popup has never been seen before', async () => {
258259
sandbox.stub(window, 'showInformationMessage').resolvesArg(3 /* "yes" item */);
259260
await ctx.globalState.update('telemetry-request-viewed', false);
260261
await enableTelemetry('codeQL.telemetry', false);

extensions/ql-vscode/src/vscode-tests/run-integration-tests.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { TestOptions } from 'vscode-test/out/runTest';
2121
// that might show up with new vscode versions released, even though
2222
// this makes testing not-quite-pure, but it can be changed for local
2323
// testing against old versions if necessary.
24-
const VSCODE_VERSION = 'stable';
24+
const VSCODE_VERSION = '1.52.1';
2525

2626
// List if test dirs
2727
// - no-workspace - Tests with no workspace selected upon launch.
@@ -77,14 +77,12 @@ async function main() {
7777
const testDirsString = process.argv[2];
7878
const dirs = testDirsString.split(',').map(dir => dir.trim().toLocaleLowerCase());
7979

80-
if (dirs.includes(TestDir.CliIntegration)) {
81-
console.log('Installing required extensions');
82-
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
83-
cp.spawnSync(cliPath, ['--install-extension', 'hbenl.vscode-test-explorer'], {
84-
encoding: 'utf-8',
85-
stdio: 'inherit'
86-
});
87-
}
80+
console.log('Installing required extensions');
81+
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
82+
cp.spawnSync(cliPath, ['--install-extension', 'hbenl.vscode-test-explorer'], {
83+
encoding: 'utf-8',
84+
stdio: 'inherit'
85+
});
8886

8987
console.log(`Running integration tests in these directories: ${dirs}`);
9088
for (const dir of dirs) {
@@ -115,12 +113,10 @@ function getLaunchArgs(dir: TestDir) {
115113
switch (dir) {
116114
case TestDir.NoWorksspace:
117115
return [
118-
'--disable-extensions'
119116
];
120117

121118
case TestDir.MinimalWorksspace:
122119
return [
123-
'--disable-extensions',
124120
path.resolve(__dirname, '../../test/data')
125121
];
126122

@@ -134,5 +130,4 @@ function getLaunchArgs(dir: TestDir) {
134130
default:
135131
assertNever(dir);
136132
}
137-
return undefined;
138133
}

0 commit comments

Comments
 (0)