diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/config.ts | 2 | ||||
-rw-r--r-- | editors/code/src/run.ts | 2 | ||||
-rw-r--r-- | editors/code/tests/unit/runnable_env.test.ts | 60 |
3 files changed, 32 insertions, 32 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 3257275c5..23975c726 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -5,7 +5,7 @@ export type UpdatesChannel = "stable" | "nightly"; | |||
5 | 5 | ||
6 | export const NIGHTLY_TAG = "nightly"; | 6 | export const NIGHTLY_TAG = "nightly"; |
7 | 7 | ||
8 | export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string, env: Record<string, string>; }[]; | 8 | export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string; env: Record<string, string> }[]; |
9 | 9 | ||
10 | export class Config { | 10 | export class Config { |
11 | readonly extensionId = "matklad.rust-analyzer"; | 11 | readonly extensionId = "matklad.rust-analyzer"; |
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 4a5c6ad41..c09954614 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts | |||
@@ -111,7 +111,7 @@ export function prepareEnv(runnable: ra.Runnable, runnableEnvCfg: RunnableEnvCfg | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | } else { | 113 | } else { |
114 | Object.assign(env, runnableEnvCfg as Record<string, string>); | 114 | Object.assign(env, runnableEnvCfg); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/editors/code/tests/unit/runnable_env.test.ts b/editors/code/tests/unit/runnable_env.test.ts index 979d497dd..f2f53e91a 100644 --- a/editors/code/tests/unit/runnable_env.test.ts +++ b/editors/code/tests/unit/runnable_env.test.ts | |||
@@ -3,7 +3,7 @@ import { prepareEnv } from '../../src/run'; | |||
3 | import { RunnableEnvCfg } from '../../src/config'; | 3 | import { RunnableEnvCfg } from '../../src/config'; |
4 | import * as ra from '../../src/lsp_ext'; | 4 | import * as ra from '../../src/lsp_ext'; |
5 | 5 | ||
6 | function make_runnable(label: string): ra.Runnable { | 6 | function makeRunnable(label: string): ra.Runnable { |
7 | return { | 7 | return { |
8 | label, | 8 | label, |
9 | kind: "cargo", | 9 | kind: "cargo", |
@@ -11,21 +11,21 @@ function make_runnable(label: string): ra.Runnable { | |||
11 | cargoArgs: [], | 11 | cargoArgs: [], |
12 | executableArgs: [] | 12 | executableArgs: [] |
13 | } | 13 | } |
14 | } | 14 | }; |
15 | } | 15 | } |
16 | 16 | ||
17 | function fakePrepareEnv(runnable_name: string, config: RunnableEnvCfg) : Record<string, string> { | 17 | function fakePrepareEnv(runnableName: string, config: RunnableEnvCfg): Record<string, string> { |
18 | const runnable = make_runnable(runnable_name); | 18 | const runnable = makeRunnable(runnableName); |
19 | return prepareEnv(runnable, config); | 19 | return prepareEnv(runnable, config); |
20 | } | 20 | } |
21 | 21 | ||
22 | suite('Runnable env', () => { | 22 | suite('Runnable env', () => { |
23 | test('Global config works', () => { | 23 | test('Global config works', () => { |
24 | const bin_env = fakePrepareEnv("run project_name", {"GLOBAL": "g"}); | 24 | const binEnv = fakePrepareEnv("run project_name", { "GLOBAL": "g" }); |
25 | assert.equal(bin_env["GLOBAL"], "g"); | 25 | assert.equal(binEnv["GLOBAL"], "g"); |
26 | 26 | ||
27 | const test_env = fakePrepareEnv("test some::mod::test_name", {"GLOBAL": "g"}); | 27 | const testEnv = fakePrepareEnv("test some::mod::test_name", { "GLOBAL": "g" }); |
28 | assert.equal(test_env["GLOBAL"], "g"); | 28 | assert.equal(testEnv["GLOBAL"], "g"); |
29 | }); | 29 | }); |
30 | 30 | ||
31 | test('null mask works', () => { | 31 | test('null mask works', () => { |
@@ -34,11 +34,11 @@ suite('Runnable env', () => { | |||
34 | env: { DATA: "data" } | 34 | env: { DATA: "data" } |
35 | } | 35 | } |
36 | ]; | 36 | ]; |
37 | const bin_env = fakePrepareEnv("run project_name", config); | 37 | const binEnv = fakePrepareEnv("run project_name", config); |
38 | assert.equal(bin_env["DATA"], "data"); | 38 | assert.equal(binEnv["DATA"], "data"); |
39 | 39 | ||
40 | const test_env = fakePrepareEnv("test some::mod::test_name", config); | 40 | const testEnv = fakePrepareEnv("test some::mod::test_name", config); |
41 | assert.equal(test_env["DATA"], "data"); | 41 | assert.equal(testEnv["DATA"], "data"); |
42 | }); | 42 | }); |
43 | 43 | ||
44 | test('order works', () => { | 44 | test('order works', () => { |
@@ -50,11 +50,11 @@ suite('Runnable env', () => { | |||
50 | env: { DATA: "newdata" } | 50 | env: { DATA: "newdata" } |
51 | } | 51 | } |
52 | ]; | 52 | ]; |
53 | const bin_env = fakePrepareEnv("run project_name", config); | 53 | const binEnv = fakePrepareEnv("run project_name", config); |
54 | assert.equal(bin_env["DATA"], "newdata"); | 54 | assert.equal(binEnv["DATA"], "newdata"); |
55 | 55 | ||
56 | const test_env = fakePrepareEnv("test some::mod::test_name", config); | 56 | const testEnv = fakePrepareEnv("test some::mod::test_name", config); |
57 | assert.equal(test_env["DATA"], "newdata"); | 57 | assert.equal(testEnv["DATA"], "newdata"); |
58 | }); | 58 | }); |
59 | 59 | ||
60 | test('mask works', () => { | 60 | test('mask works', () => { |
@@ -71,14 +71,14 @@ suite('Runnable env', () => { | |||
71 | env: { DATA: "special_test" } | 71 | env: { DATA: "special_test" } |
72 | } | 72 | } |
73 | ]; | 73 | ]; |
74 | const bin_env = fakePrepareEnv("run project_name", config); | 74 | const binEnv = fakePrepareEnv("run project_name", config); |
75 | assert.equal(bin_env["DATA"], "rundata"); | 75 | assert.equal(binEnv["DATA"], "rundata"); |
76 | 76 | ||
77 | const test_env = fakePrepareEnv("test some::mod::test_name", config); | 77 | const testEnv = fakePrepareEnv("test some::mod::test_name", config); |
78 | assert.equal(test_env["DATA"], "data"); | 78 | assert.equal(testEnv["DATA"], "data"); |
79 | 79 | ||
80 | const special_test_env = fakePrepareEnv("test some::mod::special_test", config); | 80 | const specialTestEnv = fakePrepareEnv("test some::mod::special_test", config); |
81 | assert.equal(special_test_env["DATA"], "special_test"); | 81 | assert.equal(specialTestEnv["DATA"], "special_test"); |
82 | }); | 82 | }); |
83 | 83 | ||
84 | test('exact test name works', () => { | 84 | test('exact test name works', () => { |
@@ -91,11 +91,11 @@ suite('Runnable env', () => { | |||
91 | env: { DATA: "test special" } | 91 | env: { DATA: "test special" } |
92 | } | 92 | } |
93 | ]; | 93 | ]; |
94 | const test_env = fakePrepareEnv("test some::mod::test_name", config); | 94 | const testEnv = fakePrepareEnv("test some::mod::test_name", config); |
95 | assert.equal(test_env["DATA"], "test special"); | 95 | assert.equal(testEnv["DATA"], "test special"); |
96 | 96 | ||
97 | const special_test_env = fakePrepareEnv("test some::mod::another_test", config); | 97 | const specialTestEnv = fakePrepareEnv("test some::mod::another_test", config); |
98 | assert.equal(special_test_env["DATA"], "data"); | 98 | assert.equal(specialTestEnv["DATA"], "data"); |
99 | }); | 99 | }); |
100 | 100 | ||
101 | test('test mod name works', () => { | 101 | test('test mod name works', () => { |
@@ -108,11 +108,11 @@ suite('Runnable env', () => { | |||
108 | env: { DATA: "mod special" } | 108 | env: { DATA: "mod special" } |
109 | } | 109 | } |
110 | ]; | 110 | ]; |
111 | const test_env = fakePrepareEnv("test some::mod::test_name", config); | 111 | const testEnv = fakePrepareEnv("test some::mod::test_name", config); |
112 | assert.equal(test_env["DATA"], "mod special"); | 112 | assert.equal(testEnv["DATA"], "mod special"); |
113 | 113 | ||
114 | const special_test_env = fakePrepareEnv("test some::mod::another_test", config); | 114 | const specialTestEnv = fakePrepareEnv("test some::mod::another_test", config); |
115 | assert.equal(special_test_env["DATA"], "mod special"); | 115 | assert.equal(specialTestEnv["DATA"], "mod special"); |
116 | }); | 116 | }); |
117 | 117 | ||
118 | }); | 118 | }); |