Skip to content

Commit 1b8702c

Browse files
committed
test(linter): add basic linter activation tests
Tests the activation, dispose, and linter commands
1 parent 2026090 commit 1b8702c

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

test/integration/linter.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as vscode from 'vscode';
2+
import * as path from 'path';
3+
import { strictEqual } from 'assert';
4+
import { FortranLintingProvider } from '../../src/features/linter-provider';
5+
import {
6+
CleanLintDiagnostics,
7+
CleanLintFiles,
8+
InitLint,
9+
RescanLint,
10+
} from '../../src/features/commands';
11+
12+
suite('Linter', async () => {
13+
let doc: vscode.TextDocument;
14+
const fileUri = vscode.Uri.file(path.resolve(__dirname, '../../../test/fortran/sample.f90'));
15+
const linter = new FortranLintingProvider();
16+
17+
suiteSetup(async () => {
18+
doc = await vscode.workspace.openTextDocument(fileUri);
19+
await vscode.window.showTextDocument(doc);
20+
});
21+
22+
test('Check disposables array has been populated', async () => {
23+
await linter.activate();
24+
strictEqual(linter['subscriptions'].length > 1, true);
25+
});
26+
27+
// test(`Run command ${InitLint}`, async () => {
28+
// await vscode.commands.executeCommand(InitLint);
29+
// });
30+
31+
test(`Run command is ${RescanLint}`, async () => {
32+
await vscode.commands.executeCommand(RescanLint);
33+
});
34+
35+
test(`Run command ${CleanLintDiagnostics}`, async () => {
36+
await vscode.commands.executeCommand(CleanLintDiagnostics);
37+
});
38+
39+
test(`Run command ${CleanLintFiles}`, async () => {
40+
await vscode.commands.executeCommand(CleanLintFiles);
41+
});
42+
43+
test('Check disposables have been cleared', () => {
44+
linter.dispose();
45+
strictEqual(linter['subscriptions'].length, 0);
46+
});
47+
});

test/integration/runTest.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import * as path from 'path';
22

3-
import { runTests } from '@vscode/test-electron';
3+
import {
4+
runTests,
5+
downloadAndUnzipVSCode,
6+
resolveCliArgsFromVSCodeExecutablePath,
7+
} from '@vscode/test-electron';
48
import { spawnSync } from 'child_process';
59

610
async function main() {
@@ -25,15 +29,22 @@ async function main() {
2529
// Passed to `--extensionDevelopmentPath`
2630
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
2731
const workspacePath = path.resolve(__dirname, '../../../test/fortran/');
32+
// Install the C++ extension
33+
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
34+
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
35+
spawnSync(cli, [...args, '--install-extension', 'ms-vscode.cpptools'], {
36+
encoding: 'utf-8',
37+
stdio: 'inherit',
38+
});
2839

2940
// The path to the extension test runner script
3041
// Passed to --extensionTestsPath
3142
const extensionTestsPath = path.resolve(__dirname, './index');
3243

33-
const launchArgs = [workspacePath, '--disable-extensions'];
44+
const launchArgs = [workspacePath];
3445
// Download VS Code, unzip it and run the integration test
3546
await runTests({
36-
launchArgs,
47+
launchArgs: launchArgs,
3748
extensionDevelopmentPath,
3849
extensionTestsPath,
3950
});

0 commit comments

Comments
 (0)