Skip to content

Commit 3f4eb6e

Browse files
committed
Merge branch 'test-suite' of https://github.com/jneira/vscode-haskell into test-suite
2 parents b8356ac + 20a2094 commit 3f4eb6e

File tree

9 files changed

+118
-30
lines changed

9 files changed

+118
-30
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
os: [macos-latest, ubuntu-latest, windows-latest]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
- name: Install Node.js
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 10.x
22+
- run: npm ci
23+
- run: xvfb-run -a npm test
24+
if: runner.os == 'Linux'
25+
- run: npm test
26+
if: runner.os != 'Linux'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
"tslint-fix": "tslint --fix -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
369369
"push-tag": "git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version",
370370
"pretest": "tsc -p ./",
371-
"test": "node ./out/src/test/runTest.js"
371+
"test": "node ./out/test/runTest.js"
372372
},
373373
"husky": {
374374
"hooks": {

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
196196
args = args.concat(['-l', logFile]);
197197
}
198198

199-
let extraArgs: string = workspace.getConfiguration('haskell', uri).serverExtraArgs;
199+
const extraArgs: string = workspace.getConfiguration('haskell', uri).serverExtraArgs;
200200
if (extraArgs !== '') {
201201
args = args.concat(extraArgs.split(' '));
202202
}

src/test/runTest.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/suite/extension.test.ts

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

8+
function getExtension(extId: string) {
9+
return vscode.extensions.getExtension(extId);
10+
}
11+
812
suite('Extension Test Suite', () => {
913
vscode.window.showInformationMessage('Start all tests.');
1014

11-
test('Sample test', () => {
12-
assert.strictEqual([1, 2, 3].indexOf(5), -1);
13-
assert.strictEqual([1, 2, 3].indexOf(0), -1);
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+
});
1429
});
1530
});

test/runTest.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as cp from 'child_process';
2+
import * as path from 'path';
3+
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+
}
13+
14+
async function main() {
15+
try {
16+
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
17+
18+
// We have to install this dependant extension
19+
installExtension(vscodeExecutablePath, 'justusadam.language-haskell');
20+
21+
// The folder containing the Extension Manifest package.json
22+
// Passed to `--extensionDevelopmentPath`
23+
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
24+
25+
// The path to the extension test runner script
26+
// Passed to --extensionTestsPath
27+
const extensionTestsPath = path.resolve(__dirname, './suite/index');
28+
29+
// Download VS Code, unzip it and run the integration test
30+
await runTests({
31+
vscodeExecutablePath,
32+
extensionDevelopmentPath,
33+
extensionTestsPath,
34+
launchArgs: [
35+
// '--disable-extensions'
36+
],
37+
});
38+
} catch (err) {
39+
console.error(err);
40+
console.error('Failed to run tests');
41+
process.exit(1);
42+
}
43+
}
44+
45+
main();

test/suite/extension.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
return getExtension('haskell.haskell')
21+
?.activate()
22+
.then(() => {
23+
assert.ok(true);
24+
});
25+
});
26+
});
File renamed without changes.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"noFallthroughCasesInSwitch": true,
1515
"strictNullChecks": true
1616
},
17-
"include": ["src/**/*"],
17+
"include": ["src/**/*", "test/**/*"],
1818
"exclude": ["node_modules", ".vscode-test"]
1919
}

0 commit comments

Comments
 (0)