-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #560
- Loading branch information
Showing
8 changed files
with
1,866 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// https://github.com/microsoft/vscode-test-cli | ||
import { defineConfig } from '@vscode/test-cli'; | ||
import { execSync } from 'child_process'; | ||
|
||
let vscode_path = undefined; | ||
try { | ||
const m = execSync('chcp 65001 && reg query HKCR\\vscode\\shell\\open\\command', { encoding: 'utf8' }) | ||
.match(/REG_SZ\s+("([^"]+)"|\S+)/); | ||
vscode_path = m[2] || m[1]; | ||
} catch { }; | ||
|
||
export default defineConfig({ | ||
files: 'client/dist/test/**/*.test.js', | ||
useInstallation: vscode_path && { | ||
fromPath: vscode_path | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as assert from 'assert'; | ||
import * as vscode from 'vscode'; | ||
import { resolve } from 'path'; | ||
import { LanguageClient } from 'vscode-languageclient/node'; | ||
import * as lsp from 'vscode-languageserver-protocol'; | ||
|
||
let client: LanguageClient | undefined; | ||
|
||
suite('Start ahk language server', () => { | ||
let isRunning = false; | ||
setup(async () => { | ||
client = await vscode.extensions.getExtension('thqby.vscode-autohotkey2-lsp')?.activate(); | ||
isRunning = client?.isRunning() ?? false; | ||
await vscode.commands.executeCommand('workbench.action.closeAllEditors'); | ||
}); | ||
|
||
test('language server is running?', () => assert.equal(isRunning, true)); | ||
|
||
test('test language server', async () => { | ||
if (!isRunning) | ||
throw Error(); | ||
const te = await vscode.window.showTextDocument(await vscode.workspace.openTextDocument( | ||
resolve(__dirname, '../../../server/dist/ahkProvider.ahk') | ||
)); | ||
let request: string; | ||
const uri = te.document.uri.toString(); | ||
await client!.sendNotification(lsp.DidChangeTextDocumentNotification.method, | ||
{ textDocument: { uri } } as lsp.DidChangeTextDocumentParams); | ||
const content = await client!.sendRequest(request = 'ahk2.getContent', uri) as string; | ||
assert.equal(te.document.getText() === content, true, request); | ||
|
||
}).timeout(20000); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { resolve } from 'path'; | ||
import * as Mocha from 'mocha'; | ||
import { readdir } from 'fs'; | ||
|
||
export function run(): Promise<void> { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd', | ||
timeout: 30000 | ||
}); | ||
|
||
return new Promise((c, e) => { | ||
readdir(__dirname, (err, files) => { | ||
if (err) { | ||
return e(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => f.endsWith('.test.js') && mocha.addFile(resolve(__dirname, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
e(err); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.