Skip to content

Commit 0e8cf49

Browse files
committed
Move tests to top directory
1 parent 1f9d62a commit 0e8cf49

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

src/test/suite/extension.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as assert from 'assert';
2+
3+
// You can import and use all API from the 'vscode' module
4+
// as well as import your extension to test it
5+
import * as vscode from 'vscode';
6+
// import * as haskell from '../../extension';
7+
8+
function getExtension(extId: string) {
9+
return vscode.extensions.getExtension(extId);
10+
}
11+
12+
suite('Extension Test Suite', () => {
13+
vscode.window.showInformationMessage('Start all tests.');
14+
15+
test('Extension should be present', () => {
16+
assert.ok(getExtension('haskell.haskell'));
17+
});
18+
19+
test('should activate', () => {
20+
getExtension('justusadam.language-haskell')
21+
?.activate()
22+
.then(() => {
23+
getExtension('haskell.haskell')
24+
?.activate()
25+
.then(() => {
26+
assert.ok(true);
27+
});
28+
});
29+
});
30+
});

test/runTest.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import * as cp from 'child_process';
12
import * as path from 'path';
23

3-
import { runTests } from '@vscode/test-electron';
4+
import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from '@vscode/test-electron';
5+
6+
function installExtension(vscodeExePath: string, extId: string) {
7+
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExePath);
8+
cp.spawnSync(cliPath, ['--install-extension', extId], {
9+
encoding: 'utf-8',
10+
stdio: 'inherit',
11+
});
12+
}
413

514
async function main() {
615
try {
16+
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
17+
18+
// We have to install this dependant extension
19+
installExtension(vscodeExecutablePath, 'justusadam.language-haskell');
20+
721
// The folder containing the Extension Manifest package.json
822
// Passed to `--extensionDevelopmentPath`
923
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
@@ -14,8 +28,12 @@ async function main() {
1428

1529
// Download VS Code, unzip it and run the integration test
1630
await runTests({
31+
vscodeExecutablePath,
1732
extensionDevelopmentPath,
1833
extensionTestsPath,
34+
launchArgs: [
35+
// '--disable-extensions'
36+
],
1937
});
2038
} catch (err) {
2139
console.error(err);

test/suite/extension.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import * as assert from 'assert';
55
import * as vscode from 'vscode';
66
// import * as haskell from '../../extension';
77

8-
function getExtension() {
9-
return vscode.extensions.getExtension('haskell.haskell');
8+
function getExtension(extId: string) {
9+
return vscode.extensions.getExtension(extId);
1010
}
1111

1212
suite('Extension Test Suite', () => {
1313
vscode.window.showInformationMessage('Start all tests.');
1414

1515
test('Extension should be present', () => {
16-
assert.ok(getExtension());
16+
assert.ok(getExtension('haskell.haskell'));
1717
});
1818

1919
test('should activate', () => {
20-
return getExtension()
20+
return getExtension('haskell.haskell')
2121
?.activate()
2222
.then(() => {
2323
assert.ok(true);

0 commit comments

Comments
 (0)