|
1 | 1 | /* eslint-disable no-process-env */
|
2 | 2 | import * as assert from "assert";
|
3 | 3 | import * as path from "path";
|
| 4 | +import os from "os"; |
4 | 5 |
|
5 | 6 | import * as vscode from "vscode";
|
6 | 7 | import sinon from "sinon";
|
@@ -167,4 +168,45 @@ suite("Ruby environment activation", () => {
|
167 | 168 |
|
168 | 169 | assert.deepStrictEqual(ruby.env, { BUNDLE_GEMFILE: ".ruby-lsp/Gemfile" });
|
169 | 170 | });
|
| 171 | + |
| 172 | + test("Adds local exe directory to PATH when working on the Ruby LSP itself", async () => { |
| 173 | + if (os.platform() === "win32") { |
| 174 | + // We don't mutate the path on Windows |
| 175 | + return; |
| 176 | + } |
| 177 | + |
| 178 | + const manager = process.env.CI |
| 179 | + ? ManagerIdentifier.None |
| 180 | + : ManagerIdentifier.Chruby; |
| 181 | + |
| 182 | + const configStub = sinon |
| 183 | + .stub(vscode.workspace, "getConfiguration") |
| 184 | + .returns({ |
| 185 | + get: (name: string) => { |
| 186 | + if (name === "rubyVersionManager") { |
| 187 | + return { identifier: manager }; |
| 188 | + } else if (name === "bundleGemfile") { |
| 189 | + return ""; |
| 190 | + } |
| 191 | + |
| 192 | + return undefined; |
| 193 | + }, |
| 194 | + } as unknown as vscode.WorkspaceConfiguration); |
| 195 | + |
| 196 | + const workspacePath = path.dirname( |
| 197 | + path.dirname(path.dirname(path.dirname(__dirname))), |
| 198 | + ); |
| 199 | + const lspFolder: vscode.WorkspaceFolder = { |
| 200 | + uri: vscode.Uri.file(workspacePath), |
| 201 | + name: path.basename(workspacePath), |
| 202 | + index: 0, |
| 203 | + }; |
| 204 | + const ruby = new Ruby(context, lspFolder, outputChannel, FAKE_TELEMETRY); |
| 205 | + await ruby.activateRuby(); |
| 206 | + |
| 207 | + const firstEntry = ruby.env.PATH!.split(path.delimiter)[0]; |
| 208 | + assert.match(firstEntry, /ruby-lsp\/exe$/); |
| 209 | + |
| 210 | + configStub.restore(); |
| 211 | + }).timeout(10000); |
170 | 212 | });
|
0 commit comments