Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Aug 16, 2024
1 parent 9d0417c commit ffec552
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion vscode/src/test/suite/ruby/rubyInstaller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import assert from "assert";
import path from "path";
import os from "os";

import sinon from "sinon";
import { before, after } from "mocha";
import * as vscode from "vscode";

import { RubyInstaller } from "../../../ruby/rubyInstaller";
import { WorkspaceChannel } from "../../../workspaceChannel";
import { LOG_CHANNEL } from "../../../common";
import { asyncExec, LOG_CHANNEL } from "../../../common";
import { RUBY_VERSION } from "../../rubyVersion";

suite("RubyInstaller", () => {
Expand Down Expand Up @@ -100,4 +101,43 @@ suite("RubyInstaller", () => {
force: true,
});
});

test("Finds Ruby using Powershell", async () => {
const [major, minor, _patch] = RUBY_VERSION.split(".").map(Number);
fs.symlinkSync(
path.join(
"C:",
"hostedtoolcache",
"windows",
"Ruby",
RUBY_VERSION,
"x64",
),
path.join("C:", `Ruby${major}${minor}-${os.arch()}`),
);

fs.writeFileSync(path.join(workspacePath, ".ruby-version"), RUBY_VERSION);

const windows = new RubyInstaller(workspaceFolder, outputChannel);

const { stdout } = await asyncExec(
'powershell -Command \\"(Get-Command pwsh.exe).Path\\"',
);
// eslint-disable-next-line no-console
console.log(stdout);
const stub = sinon.stub(vscode.env, "shell").returns(stdout.trim());

const { env, version, yjit } = await windows.activate();
stub.restore();

assert.match(env.GEM_PATH!, /ruby\/3\.3\.0/);
assert.match(env.GEM_PATH!, /lib\/ruby\/gems\/3\.3\.0/);
assert.strictEqual(version, RUBY_VERSION);
assert.notStrictEqual(yjit, undefined);

fs.rmSync(path.join("C:", `Ruby${major}${minor}-${os.arch()}`), {
recursive: true,
force: true,
});
});
});

0 comments on commit ffec552

Please sign in to comment.