|
| 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