fix: patch ci (#145)

This commit is contained in:
Charles Packer
2025-12-01 22:46:43 -08:00
committed by GitHub
parent bc558e5c5b
commit a30f170c30
4 changed files with 269 additions and 68 deletions

View File

@@ -0,0 +1,36 @@
import { expect, test } from "bun:test";
import { shell_command } from "../../tools/impl/ShellCommand.js";
test("shell_command executes basic echo", async () => {
const result = await shell_command({ command: "echo shell-basic" });
expect(result.output).toContain("shell-basic");
});
test("shell_command falls back when preferred shell is missing", async () => {
const marker = "shell-fallback";
if (process.platform === "win32") {
const originalUpper = process.env.COMSPEC;
const originalLower = process.env.ComSpec;
process.env.COMSPEC = "C:/missing-shell.exe";
process.env.ComSpec = "C:/missing-shell.exe";
try {
const result = await shell_command({ command: `echo ${marker}` });
expect(result.output).toContain(marker);
} finally {
if (originalUpper === undefined) delete process.env.COMSPEC;
else process.env.COMSPEC = originalUpper;
if (originalLower === undefined) delete process.env.ComSpec;
else process.env.ComSpec = originalLower;
}
} else {
const original = process.env.SHELL;
process.env.SHELL = "/nonexistent-shell";
try {
const result = await shell_command({ command: `echo ${marker}` });
expect(result.output).toContain(marker);
} finally {
if (original === undefined) delete process.env.SHELL;
else process.env.SHELL = original;
}
}
});