aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/test/index.ts22
-rw-r--r--editors/code/src/test/runTest.ts22
-rw-r--r--editors/code/src/test/utils/index.ts49
-rw-r--r--editors/code/src/utils/diagnostics/rust.ts2
4 files changed, 72 insertions, 23 deletions
diff --git a/editors/code/src/test/index.ts b/editors/code/src/test/index.ts
deleted file mode 100644
index 6e565c254..000000000
--- a/editors/code/src/test/index.ts
+++ /dev/null
@@ -1,22 +0,0 @@
1//
2// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3//
4// This file is providing the test runner to use when running extension tests.
5// By default the test runner in use is Mocha based.
6//
7// You can provide your own test runner if you want to override it by exporting
8// a function run(testRoot: string, clb: (error:Error) => void) that the extension
9// host can call to run the tests. The test runner is expected to use console.log
10// to report the results back to the caller. When the tests are finished, return
11// a possible error to the callback or null if none.
12
13import * as testRunner from 'vscode/lib/testrunner';
14
15// You can directly control Mocha options by uncommenting the following lines
16// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17testRunner.configure({
18 ui: 'bdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19 useColors: true // colored output from test results
20});
21
22module.exports = testRunner;
diff --git a/editors/code/src/test/runTest.ts b/editors/code/src/test/runTest.ts
new file mode 100644
index 000000000..d880d47df
--- /dev/null
+++ b/editors/code/src/test/runTest.ts
@@ -0,0 +1,22 @@
1import * as path from 'path';
2
3import { runTests } from 'vscode-test';
4
5async function main() {
6 try {
7 // The folder containing the Extension Manifest package.json
8 // Passed to `--extensionDevelopmentPath`
9 const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10
11 // The path to the extension test runner script
12 // Passed to --extensionTestsPath
13 const extensionTestsPath = path.resolve(__dirname, './utils/index');
14
15 // Download VS Code, unzip it and run the integration test
16 await runTests({ extensionDevelopmentPath, extensionTestsPath });
17 } catch (err) {
18 process.exit(1);
19 }
20}
21
22main();
diff --git a/editors/code/src/test/utils/index.ts b/editors/code/src/test/utils/index.ts
new file mode 100644
index 000000000..16715a286
--- /dev/null
+++ b/editors/code/src/test/utils/index.ts
@@ -0,0 +1,49 @@
1//
2// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3//
4// This file is providing the test runner to use when running extension tests.
5// By default the test runner in use is Mocha based.
6//
7// You can provide your own test runner if you want to override it by exporting
8// a function run(testRoot: string, clb: (error:Error) => void) that the extension
9// host can call to run the tests. The test runner is expected to use console.log
10// to report the results back to the caller. When the tests are finished, return
11// a possible error to the callback or null if none.
12
13import * as glob from 'glob';
14import * as Mocha from 'mocha';
15import * as path from 'path';
16
17export function run(): Promise<void> {
18 // Create the mocha test
19 const mocha = new Mocha({
20 ui: 'bdd'
21 });
22 mocha.useColors(true);
23
24 const testsRoot = __dirname;
25
26 return new Promise((c, e) => {
27 glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
28 if (err) {
29 return e(err);
30 }
31
32 // Add files to the test suite
33 files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
34
35 try {
36 // Run the mocha test
37 mocha.run(failures => {
38 if (failures > 0) {
39 e(new Error(`${failures} tests failed.`));
40 } else {
41 c();
42 }
43 });
44 } catch (err) {
45 e(err);
46 }
47 });
48 });
49}
diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts
index bfb494a3a..1fb1f7b6d 100644
--- a/editors/code/src/utils/diagnostics/rust.ts
+++ b/editors/code/src/utils/diagnostics/rust.ts
@@ -64,7 +64,7 @@ function mapLevelToSeverity(s: string): vscode.DiagnosticSeverity {
64 * Converts a Rust span to a VsCode location 64 * Converts a Rust span to a VsCode location
65 */ 65 */
66function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location { 66function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
67 const fileName = path.join(vscode.workspace.rootPath!, span.file_name); 67 const fileName = path.join(vscode.workspace.rootPath || '', span.file_name);
68 const fileUri = vscode.Uri.file(fileName); 68 const fileUri = vscode.Uri.file(fileName);
69 69
70 const range = new vscode.Range( 70 const range = new vscode.Range(