diff options
| author | vsrs <vit@conrlab.com> | 2020-07-02 21:33:26 +0300 |
|---|---|---|
| committer | vsrs <vit@conrlab.com> | 2020-07-03 14:23:51 +0300 |
| commit | 271abb7bc43f11c9b9e9c1353b162d9d267b1d21 (patch) | |
| tree | 5bf0cbdcbfa09535dca9db7cc02cbc4d6153889a /editors/code/src | |
| parent | 7b79d24ad5b251c0806a07aa7769e824f3c37fec (diff) | |
| download | rust-271abb7bc43f11c9b9e9c1353b162d9d267b1d21.tar.gz rust-271abb7bc43f11c9b9e9c1353b162d9d267b1d21.zip | |
Add tests
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/config.ts | 4 | ||||
| -rw-r--r-- | editors/code/src/debug.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/run.ts | 14 |
3 files changed, 10 insertions, 10 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index a317aabcb1c..3257275c56f 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -5,7 +5,7 @@ export type UpdatesChannel = "stable" | "nightly"; export const NIGHTLY_TAG = "nightly"; -export type RunnableEnvCfg = Record<string, string> | [{ mask?: string, env: Record<string, string>; }] +export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string, env: Record<string, string>; }[]; export class Config { readonly extensionId = "matklad.rust-analyzer"; @@ -117,7 +117,7 @@ export class Config { } get runnableEnv() { - return this.get<RunnableEnvCfg | undefined>("runnableEnv"); + return this.get<RunnableEnvCfg>("runnableEnv"); } get debug() { diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 525d26923ae..bd92c5b6d73 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -93,7 +93,7 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v } const executable = await getDebugExecutable(runnable); - const env = prepareEnv(runnable, ctx.config); + const env = prepareEnv(runnable, ctx.config.runnableEnv); const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, debugOptions.sourceFileMap); if (debugConfig.type in debugOptions.engineSettings) { const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type]; diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index d7c7c489c98..4a5c6ad4125 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts @@ -5,7 +5,7 @@ import * as tasks from './tasks'; import { Ctx } from './ctx'; import { makeDebugConfig } from './debug'; -import { Config } from './config'; +import { Config, RunnableEnvCfg } from './config'; const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }]; @@ -96,22 +96,22 @@ export class RunnableQuickPick implements vscode.QuickPickItem { } } -export function prepareEnv(runnable: ra.Runnable, config: Config): Record<string, string> { +export function prepareEnv(runnable: ra.Runnable, runnableEnvCfg: RunnableEnvCfg): Record<string, string> { const env: Record<string, string> = { "RUST_BACKTRACE": "short" }; if (runnable.args.expectTest) { env["UPDATE_EXPECT"] = "1"; } - if (config.runnableEnv) { - if (Array.isArray(config.runnableEnv)) { - for (const it of config.runnableEnv) { + if (runnableEnvCfg) { + if (Array.isArray(runnableEnvCfg)) { + for (const it of runnableEnvCfg) { if (!it.mask || new RegExp(it.mask).test(runnable.label)) { Object.assign(env, it.env); } } } else { - Object.assign(env, config.runnableEnv as Record<string, string>); + Object.assign(env, runnableEnvCfg as Record<string, string>); } } @@ -136,7 +136,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise command: args[0], // run, test, etc... args: args.slice(1), cwd: runnable.args.workspaceRoot, - env: prepareEnv(runnable, config), + env: prepareEnv(runnable, config.runnableEnv), }; const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() |
