Compare commits

...

1 Commits

Author SHA1 Message Date
abeatrix 166b2e9fd4 test(test): fix Windows shell execution in bash tests
Update the bash executor test helper to prefix quoted executables with the PowerShell call operator on Windows. This ensures process.execPath is invoked correctly when paths contain spaces or are quoted, keeping cross-platform test behavior consistent.
2026-05-28 17:07:37 -07:00
@@ -8,9 +8,9 @@ const ctx: AgentToolContext = {
iteration: 1,
};
function shellQuote(value: string): string {
function shellExecutable(value: string): string {
if (process.platform === "win32") {
return `'${value.replaceAll("'", "''")}'`;
return `& '${value.replaceAll("'", "''")}'`;
}
return `'${value.replaceAll("'", `'\\''`)}'`;
}
@@ -29,7 +29,7 @@ describe("createBashExecutor", () => {
it("includes stderr in combined output on success", async () => {
const bash = createBashExecutor({ combineOutput: true });
const cmd = `${shellQuote(process.execPath)} -e "process.stdout.write('ok'); process.stderr.write('warn')"`;
const cmd = `${shellExecutable(process.execPath)} -e "process.stdout.write('ok'); process.stderr.write('warn')"`;
const output = await bash(cmd, process.cwd(), ctx);
expect(output).toContain("ok");
expect(output).toContain("[stderr]");
@@ -38,7 +38,7 @@ describe("createBashExecutor", () => {
it("excludes stderr when combineOutput is false", async () => {
const bash = createBashExecutor({ combineOutput: false });
const cmd = `${shellQuote(process.execPath)} -e "process.stdout.write('ok'); process.stderr.write('warn')"`;
const cmd = `${shellExecutable(process.execPath)} -e "process.stdout.write('ok'); process.stderr.write('warn')"`;
const output = await bash(cmd, process.cwd(), ctx);
expect(output.trim()).toBe("ok");
});
@@ -53,7 +53,7 @@ describe("createBashExecutor", () => {
it("truncates output exceeding maxOutputBytes", async () => {
const bash = createBashExecutor({ maxOutputBytes: 10 });
const output = await bash(
`${shellQuote(process.execPath)} -e "process.stdout.write('a'.repeat(100))"`,
`${shellExecutable(process.execPath)} -e "process.stdout.write('a'.repeat(100))"`,
process.cwd(),
ctx,
);