From 4806cd9a51ad320b6b9fc6c8c120a281e08dc2c4 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 13 Apr 2026 20:46:10 +0700 Subject: [PATCH] fix: skip bash-dependent tests on Windows, fix platform-aware assertions - Skip worktree test suite on Windows (uses bash shell syntax) - Skip ~ home-root directory test on Windows - Make findExecutable mock assertions platform-aware (which vs where.exe) - Use nonexistent binary name for not-found test case --- packages/server/src/utils/directory-suggestions.test.ts | 4 +++- packages/server/src/utils/executable.test.ts | 6 +++--- packages/server/src/utils/worktree.test.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/server/src/utils/directory-suggestions.test.ts b/packages/server/src/utils/directory-suggestions.test.ts index a1b00e140..9eb01e864 100644 --- a/packages/server/src/utils/directory-suggestions.test.ts +++ b/packages/server/src/utils/directory-suggestions.test.ts @@ -4,6 +4,8 @@ import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { searchHomeDirectories, searchWorkspaceEntries } from "./directory-suggestions.js"; +const isWindows = process.platform === "win32"; + describe("searchHomeDirectories", () => { let tempRoot: string; let homeDir: string; @@ -101,7 +103,7 @@ describe("searchHomeDirectories", () => { expect(earlierIndex).toBeLessThan(laterIndex); }); - it("returns home-root suggestions when query is '~'", async () => { + it.skipIf(isWindows)("returns home-root suggestions when query is '~'", async () => { const results = await searchHomeDirectories({ homeDir, query: "~", diff --git a/packages/server/src/utils/executable.test.ts b/packages/server/src/utils/executable.test.ts index 94e0d6c4f..53cd412f9 100644 --- a/packages/server/src/utils/executable.test.ts +++ b/packages/server/src/utils/executable.test.ts @@ -142,9 +142,9 @@ describe("findExecutable", () => { await expect(findExecutable("codex")).resolves.toBe("/usr/local/bin/codex"); expect(execFileMock).toHaveBeenCalledWith( - "which", + process.platform === "win32" ? "where.exe" : "which", ["codex"], - { encoding: "utf8" }, + process.platform === "win32" ? { encoding: "utf8", windowsHide: true } : { encoding: "utf8" }, expect.any(Function), ); }); @@ -170,7 +170,7 @@ describe("findExecutable", () => { }, }); - await expect(findExecutable("codex")).resolves.toBeNull(); + await expect(findExecutable(missingBinaryName)).resolves.toBeNull(); }); }); diff --git a/packages/server/src/utils/worktree.test.ts b/packages/server/src/utils/worktree.test.ts index c63592c73..d385e558d 100644 --- a/packages/server/src/utils/worktree.test.ts +++ b/packages/server/src/utils/worktree.test.ts @@ -26,7 +26,7 @@ import { dirname, join } from "path"; import { tmpdir } from "os"; import net from "node:net"; -describe("createWorktree", () => { +describe.skipIf(process.platform === "win32")("createWorktree", () => { let tempDir: string; let repoDir: string; let paseoHome: string;