Skip to content

Commit 586a08c

Browse files
committed
test(lsp): added integration test for path resolution
1 parent 1c6d49b commit 586a08c

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

test/fortran/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"DEBUG": "1",
88
"VAL": ""
99
},
10+
"fortran.fortls.path": "fortls",
1011
"fortran.fortls.disableAutoupdate": true,
1112
"fortran.fortls.preprocessor.definitions": {
1213
"HAVE_ZOLTAN": "",

test/unitTest/client.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as vscode from 'vscode';
2+
import * as path from 'path';
3+
import { strictEqual } from 'assert';
4+
import { FortlsClient } from '../../src/lsp/client';
5+
import { Logger, LogLevel } from '../../src/services/logging';
6+
import { EXTENSION_ID } from '../../src/lib/tools';
7+
8+
const logger = new Logger(
9+
vscode.window.createOutputChannel('Modern Fortran', 'log'),
10+
LogLevel.DEBUG
11+
);
12+
13+
suite('Language Server integration tests', () => {
14+
const server = new FortlsClient(logger);
15+
const fileUri = vscode.Uri.file(path.resolve(__dirname, '../../../test/fortran/sample.f90'));
16+
const config = vscode.workspace.getConfiguration(EXTENSION_ID);
17+
const oldVal = config.get<string>('fortls.path');
18+
let doc: vscode.TextDocument;
19+
20+
suiteSetup(async () => {
21+
await config.update('fortls.path', './venv/bin/fortls', false);
22+
doc = await vscode.workspace.openTextDocument(fileUri);
23+
});
24+
25+
test('Local path resolution (Document URI)', async () => {
26+
const ls = await server['fortlsPath'](doc);
27+
const root = path.resolve(__dirname, '../../../test/fortran/');
28+
const ref = path.resolve(root, './venv/bin/fortls');
29+
console.log(`Reference: ${ref}`);
30+
strictEqual(ls, ref);
31+
});
32+
33+
test('Local path resolution (Document missing workspaceFolders[0])', async () => {
34+
const ls = await server['fortlsPath']();
35+
const root = path.resolve(__dirname, '../../../test/fortran/');
36+
const ref = path.resolve(root, './venv/bin/fortls');
37+
strictEqual(ls, ref);
38+
});
39+
40+
suiteTeardown(async () => {
41+
await config.update('fortls.path', oldVal, false);
42+
});
43+
});

0 commit comments

Comments
 (0)