Compare commits

...

1 Commits

Author SHA1 Message Date
BarreiroT f7f9e73d8d Fix SDK windows tests 2026-05-29 10:33:20 -07:00
@@ -8,11 +8,14 @@ const ctx: AgentToolContext = {
iteration: 1,
};
function shellQuote(value: string): string {
function nodeCommand(
jsCode: string,
): string | { command: string; args: string[] } {
if (process.platform === "win32") {
return `'${value.replaceAll("'", "''")}'`;
return { command: process.execPath, args: ["-e", jsCode] };
}
return `'${value.replaceAll("'", `'\\''`)}'`;
const quoted = `'${process.execPath.replaceAll("'", `'\\''`)}'`;
return `${quoted} -e '${jsCode.replaceAll("'", `'\\''`)}'`;
}
describe("createBashExecutor", () => {
@@ -29,7 +32,9 @@ 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 = nodeCommand(
"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 +43,9 @@ 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 = nodeCommand(
"process.stdout.write('ok'); process.stderr.write('warn')",
);
const output = await bash(cmd, process.cwd(), ctx);
expect(output.trim()).toBe("ok");
});
@@ -53,7 +60,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))"`,
nodeCommand("process.stdout.write('a'.repeat(100))"),
process.cwd(),
ctx,
);