Move lsp server to this repo (#5619)
This commit is contained in:
25
rust/kcl-language-server/client/src/test/runTest.ts
Normal file
25
rust/kcl-language-server/client/src/test/runTest.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as path from 'path'
|
||||
|
||||
import { runTests } from '@vscode/test-electron'
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../')
|
||||
|
||||
// The path to the extension test runner script
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './suite/index')
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ extensionDevelopmentPath, extensionTestsPath })
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
console.error('Failed to run tests')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
main()
|
@ -0,0 +1,16 @@
|
||||
import * as assert from 'assert'
|
||||
|
||||
// You can import and use all API from the 'vscode' module
|
||||
// as well as import your extension to test it
|
||||
import * as vscode from 'vscode'
|
||||
// import * as myExtension from '../../extension';
|
||||
|
||||
suite('Extension Test Suite', () => {
|
||||
/* eslint-disable */
|
||||
vscode.window.showInformationMessage('Start all tests.')
|
||||
|
||||
test('Sample test', () => {
|
||||
assert.strictEqual([1, 2, 3].indexOf(5), -1)
|
||||
assert.strictEqual([1, 2, 3].indexOf(0), -1)
|
||||
})
|
||||
})
|
33
rust/kcl-language-server/client/src/test/suite/index.ts
Normal file
33
rust/kcl-language-server/client/src/test/suite/index.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import * as path from 'path'
|
||||
const Mocha = require('mocha')
|
||||
const { glob } = require('glob')
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
const mocha = new Mocha({
|
||||
ui: 'tdd',
|
||||
})
|
||||
|
||||
const testsRoot = path.resolve(__dirname, '..')
|
||||
|
||||
return new Promise((c, e) => {
|
||||
glob('**/**.test.js', { cwd: testsRoot }).then((files: string[]) => {
|
||||
// Add files to the test suite
|
||||
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)))
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.run((failures: any) => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`))
|
||||
} else {
|
||||
c()
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
e(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user