about summary refs log tree commit diff
path: root/editors/code/tests
diff options
context:
space:
mode:
authorvsrs <vit@conrlab.com>2020-05-21 11:34:34 +0300
committervsrs <vit@conrlab.com>2020-05-21 11:34:34 +0300
commitc41a10c29331127ee830badddae55f3e27c9a6ea (patch)
treeb30bbcb65ff0717ea5a8b5060b288e03f157d1f5 /editors/code/tests
parent8ee40ccbe963a0a5e3e998c1652378e1035dc40d (diff)
downloadrust-c41a10c29331127ee830badddae55f3e27c9a6ea.tar.gz
rust-c41a10c29331127ee830badddae55f3e27c9a6ea.zip
Apply suggestions from @Veetaha code review
Diffstat (limited to 'editors/code/tests')
-rw-r--r--editors/code/tests/runTests.ts73
-rw-r--r--editors/code/tests/unit/index.ts10
2 files changed, 40 insertions, 43 deletions
diff --git a/editors/code/tests/runTests.ts b/editors/code/tests/runTests.ts
index 81600f6a81f..22df80ad318 100644
--- a/editors/code/tests/runTests.ts
+++ b/editors/code/tests/runTests.ts
@@ -4,43 +4,40 @@ import * as fs from 'fs';
 import { runTests } from 'vscode-test';
 
 async function main() {
-    try {
-        // The folder containing the Extension Manifest package.json
-        // Passed to `--extensionDevelopmentPath`
-        const extensionDevelopmentPath = path.resolve(__dirname, '../../');
-
-        // Minimum supported version.
-        const jsonData = fs.readFileSync(path.join(extensionDevelopmentPath, 'package.json'));
-        const json = JSON.parse(jsonData.toString());
-        let minimalVersion: string = json.engines.vscode;
-        if (minimalVersion.startsWith('^')) minimalVersion = minimalVersion.slice(1);
-
-        const launchArgs = ["--disable-extensions"];
-
-        // All test suites (either unit tests or integration tests) should be in subfolders.
-        const extensionTestsPath = path.resolve(__dirname, './unit/index');
-
-        // Run tests using the minimal supported version.
-        await runTests({
-            version: minimalVersion,
-            launchArgs,
-            extensionDevelopmentPath,
-            extensionTestsPath
-        });
-
-        // and the latest one
-        await runTests({
-            version: 'stable',
-            launchArgs,
-            extensionDevelopmentPath,
-            extensionTestsPath
-        });
-
-    } catch (err) {
-        // eslint-disable-next-line no-console
-        console.error('Failed to run tests', err);
-        process.exit(1);
-    }
+    // The folder containing the Extension Manifest package.json
+    // Passed to `--extensionDevelopmentPath`
+    const extensionDevelopmentPath = path.resolve(__dirname, '../../');
+
+    // Minimum supported version.
+    const jsonData = fs.readFileSync(path.join(extensionDevelopmentPath, 'package.json'));
+    const json = JSON.parse(jsonData.toString());
+    let minimalVersion: string = json.engines.vscode;
+    if (minimalVersion.startsWith('^')) minimalVersion = minimalVersion.slice(1);
+
+    const launchArgs = ["--disable-extensions"];
+
+    // All test suites (either unit tests or integration tests) should be in subfolders.
+    const extensionTestsPath = path.resolve(__dirname, './unit/index');
+
+    // Run tests using the minimal supported version.
+    await runTests({
+        version: minimalVersion,
+        launchArgs,
+        extensionDevelopmentPath,
+        extensionTestsPath
+    });
+
+    // and the latest one
+    await runTests({
+        version: 'stable',
+        launchArgs,
+        extensionDevelopmentPath,
+        extensionTestsPath
+    });
 }
 
-main();
+main().catch(err => {
+    // eslint-disable-next-line no-console
+    console.error('Failed to run tests', err);
+    process.exit(1);
+});
diff --git a/editors/code/tests/unit/index.ts b/editors/code/tests/unit/index.ts
index 1deb1c403d5..5165720b458 100644
--- a/editors/code/tests/unit/index.ts
+++ b/editors/code/tests/unit/index.ts
@@ -11,10 +11,10 @@ export function run(): Promise<void> {
 
     const testsRoot = __dirname;
 
-    return new Promise((c, e) => {
+    return new Promise((resolve, reject) => {
         glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
             if (err) {
-                return e(err);
+                return reject(err);
             }
 
             // Add files to the test suite
@@ -25,13 +25,13 @@ export function run(): Promise<void> {
                 mocha.timeout(100000);
                 mocha.run(failures => {
                     if (failures > 0) {
-                        e(new Error(`${failures} tests failed.`));
+                        reject(new Error(`${failures} tests failed.`));
                     } else {
-                        c();
+                        resolve();
                     }
                 });
             } catch (err) {
-                e(err);
+                reject(err);
             }
         });
     });