aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/config.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-03 14:17:36 +0100
committerGitHub <[email protected]>2020-07-03 14:17:36 +0100
commit84891455832ba871e1c5a6908ac798b7627c0c70 (patch)
treea0f4fb16c857d759b9f95e5d9322080fe76101b5 /editors/code/src/config.ts
parentf51b0cfdd6c23dd57a0a11154179730171c0425d (diff)
parent188d24024cd2770822d3e525be3ea330e79625c8 (diff)
Merge #5202
5202: Runnable env r=matklad a=vsrs This PR adds on option to specify (in the settings.json) environment variables passed to the runnable. The simplest way for all runnables in a bunch: ```jsonc "rust-analyzer.runnableEnv": { "RUN_SLOW_TESTS": "1" } ``` Or it is possible to specify vars more granularly: ```jsonc "rust-analyzer.runnableEnv": [ { // "mask": null, // null mask means that this rule will be applied for all runnables env: { "APP_ID": "1", "APP_DATA": "asdf" } }, { "mask": "test_name", "env": { "APP_ID": "2", // overwrites only APP_ID } } ] ``` You can use any valid RegExp as a mask. Also note that a full runnable name is something like *run bin_or_example_name*, *test some::mod::test_name* or *test-mod some::mod*, so it is possible to distinguish binaries, single tests, and test modules with this masks: `"^run"`, `"^test "` (the trailing space matters!), and `"^test-mod"` respectively. Fixes #4450 I suppose this info should be somewhere in the docs, but unsure where is the best place. Co-authored-by: vsrs <[email protected]>
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index fc95a7de6..23975c726 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -5,6 +5,8 @@ export type UpdatesChannel = "stable" | "nightly";
5 5
6export const NIGHTLY_TAG = "nightly"; 6export const NIGHTLY_TAG = "nightly";
7 7
8export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string; env: Record<string, string> }[];
9
8export class Config { 10export class Config {
9 readonly extensionId = "matklad.rust-analyzer"; 11 readonly extensionId = "matklad.rust-analyzer";
10 12
@@ -114,6 +116,10 @@ export class Config {
114 return this.get<string | undefined>("cargoRunner"); 116 return this.get<string | undefined>("cargoRunner");
115 } 117 }
116 118
119 get runnableEnv() {
120 return this.get<RunnableEnvCfg>("runnableEnv");
121 }
122
117 get debug() { 123 get debug() {
118 // "/rustc/<id>" used by suggestions only. 124 // "/rustc/<id>" used by suggestions only.
119 const { ["/rustc/<id>"]: _, ...sourceFileMap } = this.get<Record<string, string>>("debug.sourceFileMap"); 125 const { ["/rustc/<id>"]: _, ...sourceFileMap } = this.get<Record<string, string>>("debug.sourceFileMap");