diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2023-07-17 16:49:15 +0300 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2023-07-17 16:49:15 +0300 |
| commit | d35f6c6c11a01ee0ffb7cf762c6d20e910a7bf0e (patch) | |
| tree | 70252db1d53254b399a23613cf790fafc06d21fd /src/tools/rust-analyzer/editors/code/tests | |
| parent | 6f65ef57177ce0095171f70d0b010567c35e68cc (diff) | |
| parent | 37f84c101bca43b11027f30ab0c2852f9325bc3d (diff) | |
Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra
Diffstat (limited to 'src/tools/rust-analyzer/editors/code/tests')
4 files changed, 12 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/editors/code/tests/unit/index.ts b/src/tools/rust-analyzer/editors/code/tests/unit/index.ts index 2fa223bed4a..8ad46546abd 100644 --- a/src/tools/rust-analyzer/editors/code/tests/unit/index.ts +++ b/src/tools/rust-analyzer/editors/code/tests/unit/index.ts @@ -1,3 +1,4 @@ +import * as assert from "node:assert/strict"; import { readdir } from "fs/promises"; import * as path from "path"; @@ -30,6 +31,7 @@ class Suite { await test.promise; ok(` ✔ ${test.name}`); } catch (e) { + assert.ok(e instanceof Error); error(` ✖︎ ${test.name}\n ${e.stack}`); failed += 1; } @@ -50,6 +52,7 @@ export class Context { await ctx.run(); ok(`✔ ${name}`); } catch (e) { + assert.ok(e instanceof Error); error(`✖︎ ${name}\n ${e.stack}`); throw e; } @@ -60,7 +63,7 @@ export async function run(): Promise<void> { const context = new Context(); const testFiles = (await readdir(path.resolve(__dirname))).filter((name) => - name.endsWith(".test.js") + name.endsWith(".test.js"), ); for (const testFile of testFiles) { try { diff --git a/src/tools/rust-analyzer/editors/code/tests/unit/launch_config.test.ts b/src/tools/rust-analyzer/editors/code/tests/unit/launch_config.test.ts index 0531e064d2d..eeb8608a42d 100644 --- a/src/tools/rust-analyzer/editors/code/tests/unit/launch_config.test.ts +++ b/src/tools/rust-analyzer/editors/code/tests/unit/launch_config.test.ts @@ -1,6 +1,6 @@ import * as assert from "assert"; import { Cargo } from "../../src/toolchain"; -import { Context } from "."; +import type { Context } from "."; export async function getTests(ctx: Context) { await ctx.suite("Launch configuration/Lens", (suite) => { diff --git a/src/tools/rust-analyzer/editors/code/tests/unit/runnable_env.test.ts b/src/tools/rust-analyzer/editors/code/tests/unit/runnable_env.test.ts index b7d59e399dd..b1407ce0193 100644 --- a/src/tools/rust-analyzer/editors/code/tests/unit/runnable_env.test.ts +++ b/src/tools/rust-analyzer/editors/code/tests/unit/runnable_env.test.ts @@ -1,8 +1,8 @@ import * as assert from "assert"; import { prepareEnv } from "../../src/run"; -import { RunnableEnvCfg } from "../../src/config"; -import { Context } from "."; -import * as ra from "../../src/lsp_ext"; +import type { RunnableEnvCfg } from "../../src/config"; +import type { Context } from "."; +import type * as ra from "../../src/lsp_ext"; function makeRunnable(label: string): ra.Runnable { return { diff --git a/src/tools/rust-analyzer/editors/code/tests/unit/settings.test.ts b/src/tools/rust-analyzer/editors/code/tests/unit/settings.test.ts index 224cea5a232..bafb9569a1c 100644 --- a/src/tools/rust-analyzer/editors/code/tests/unit/settings.test.ts +++ b/src/tools/rust-analyzer/editors/code/tests/unit/settings.test.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { Context } from "."; +import type { Context } from "."; import { substituteVariablesInEnv } from "../../src/config"; export async function getTests(ctx: Context) { @@ -39,6 +39,7 @@ export async function getTests(ctx: Context) { }); suite.addTest("Should support external variables", async () => { + process.env["TEST_VARIABLE"] = "test"; const envJson = { USING_EXTERNAL_VAR: "${env:TEST_VARIABLE} test ${env:TEST_VARIABLE}", }; @@ -48,6 +49,7 @@ export async function getTests(ctx: Context) { const actualEnv = await substituteVariablesInEnv(envJson); assert.deepStrictEqual(actualEnv, expectedEnv); + delete process.env["TEST_VARIABLE"]; }); suite.addTest("should support VSCode variables", async () => { @@ -55,7 +57,7 @@ export async function getTests(ctx: Context) { USING_VSCODE_VAR: "${workspaceFolderBasename}", }; const actualEnv = await substituteVariablesInEnv(envJson); - assert.deepStrictEqual(actualEnv.USING_VSCODE_VAR, "code"); + assert.deepStrictEqual(actualEnv["USING_VSCODE_VAR"], "code"); }); }); } |
