Add tests
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user