From 609df06cb72a7fce334dc64e1fe877b6edb21186 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 8 Jan 2026 03:54:35 +0000 Subject: [PATCH] fix(ci): stabilize windows tests --- src/agents/bash-tools.test.ts | 6 ++- src/hooks/gmail-setup-utils.test.ts | 66 ++++++++++++++++------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/agents/bash-tools.test.ts b/src/agents/bash-tools.test.ts index d4295d0f1..ff5f4bad6 100644 --- a/src/agents/bash-tools.test.ts +++ b/src/agents/bash-tools.test.ts @@ -16,6 +16,8 @@ const echoAfterDelay = (message: string) => joinCommands([shortDelayCmd, `echo ${message}`]); const echoLines = (lines: string[]) => joinCommands(lines.map((line) => `echo ${line}`)); +const normalizeText = (value?: string) => + (value ?? "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim(); const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); @@ -171,7 +173,7 @@ describe("bash tool backgrounding", () => { limit: 2, }); const textBlock = log.content.find((c) => c.type === "text"); - expect(textBlock?.text?.trim()).toBe("two\nthree"); + expect(normalizeText(textBlock?.text)).toBe("two\nthree"); expect((log.details as { totalLines?: number }).totalLines).toBe(3); expect(status).toBe("completed"); }); @@ -191,7 +193,7 @@ describe("bash tool backgrounding", () => { limit: 1, }); const textBlock = log.content.find((c) => c.type === "text"); - expect(textBlock?.text?.trim()).toBe("beta"); + expect(normalizeText(textBlock?.text)).toBe("beta"); }); it("scopes process sessions by scopeKey", async () => { diff --git a/src/hooks/gmail-setup-utils.test.ts b/src/hooks/gmail-setup-utils.test.ts index 66db598aa..40b2b851b 100644 --- a/src/hooks/gmail-setup-utils.test.ts +++ b/src/hooks/gmail-setup-utils.test.ts @@ -4,46 +4,52 @@ import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; +const itUnix = process.platform === "win32" ? it.skip : it; + beforeEach(() => { vi.resetModules(); }); describe("resolvePythonExecutablePath", () => { - it("resolves a working python path and caches the result", async () => { - const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-python-")); - const originalPath = process.env.PATH; - try { - const realPython = path.join(tmp, "python-real"); - await fs.writeFile(realPython, "#!/bin/sh\nexit 0\n", "utf-8"); - await fs.chmod(realPython, 0o755); + itUnix( + "resolves a working python path and caches the result", + async () => { + const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-python-")); + const originalPath = process.env.PATH; + try { + const realPython = path.join(tmp, "python-real"); + await fs.writeFile(realPython, "#!/bin/sh\nexit 0\n", "utf-8"); + await fs.chmod(realPython, 0o755); - const shimDir = path.join(tmp, "shims"); - await fs.mkdir(shimDir, { recursive: true }); - const shim = path.join(shimDir, "python3"); - await fs.writeFile( - shim, - `#!/bin/sh\nif [ "$1" = "-c" ]; then\n echo "${realPython}"\n exit 0\nfi\nexit 1\n`, - "utf-8", - ); - await fs.chmod(shim, 0o755); + const shimDir = path.join(tmp, "shims"); + await fs.mkdir(shimDir, { recursive: true }); + const shim = path.join(shimDir, "python3"); + await fs.writeFile( + shim, + `#!/bin/sh\nif [ "$1" = "-c" ]; then\n echo "${realPython}"\n exit 0\nfi\nexit 1\n`, + "utf-8", + ); + await fs.chmod(shim, 0o755); - process.env.PATH = `${shimDir}${path.delimiter}/usr/bin`; + process.env.PATH = `${shimDir}${path.delimiter}/usr/bin`; - const { resolvePythonExecutablePath } = await import( - "./gmail-setup-utils.js" - ); + const { resolvePythonExecutablePath } = await import( + "./gmail-setup-utils.js" + ); - const resolved = await resolvePythonExecutablePath(); - expect(resolved).toBe(realPython); + const resolved = await resolvePythonExecutablePath(); + expect(resolved).toBe(realPython); - process.env.PATH = "/bin"; - const cached = await resolvePythonExecutablePath(); - expect(cached).toBe(realPython); - } finally { - process.env.PATH = originalPath; - await fs.rm(tmp, { recursive: true, force: true }); - } - }, 60_000); + process.env.PATH = "/bin"; + const cached = await resolvePythonExecutablePath(); + expect(cached).toBe(realPython); + } finally { + process.env.PATH = originalPath; + await fs.rm(tmp, { recursive: true, force: true }); + } + }, + 60_000, + ); }); describe("ensureTailscaleEndpoint", () => {