diff --git a/packages/opencode/script/kilocode/test-profile.ts b/packages/opencode/script/kilocode/test-profile.ts index 6e69d05ca3..b169404a0c 100644 --- a/packages/opencode/script/kilocode/test-profile.ts +++ b/packages/opencode/script/kilocode/test-profile.ts @@ -44,6 +44,7 @@ export namespace TestProfile { export const names = Object.keys(profiles) export function resolve(name: string, all: readonly string[]) { + const files = all.map((file) => file.replaceAll("\\", "/")) const profile = profiles[name as keyof typeof profiles] if (!profile) { return { @@ -74,7 +75,7 @@ export namespace TestProfile { ) .map(([group]) => group) const globs = patterns.map((pattern) => ({ pattern, glob: new Bun.Glob(pattern) })) - const unmatched = globs.filter((item) => !all.some((file) => item.glob.match(file))).map((item) => item.pattern) + const unmatched = globs.filter((item) => !files.some((file) => item.glob.match(file))).map((item) => item.pattern) const errors = [ malformed.length > 0 ? `Malformed patterns: ${malformed.join(", ")}` : "", duplicates.length > 0 ? `Duplicate patterns: ${duplicates.join(", ")}` : "", @@ -93,7 +94,7 @@ export namespace TestProfile { return { ok: true as const, description: profile.description, - files: all.filter((file) => globs.some((item) => item.glob.match(file))), + files: files.filter((file) => globs.some((item) => item.glob.match(file))), } } } diff --git a/packages/opencode/script/test-runner.ts b/packages/opencode/script/test-runner.ts index 04bb003351..d5551a500e 100644 --- a/packages/opencode/script/test-runner.ts +++ b/packages/opencode/script/test-runner.ts @@ -102,7 +102,9 @@ const bold = (s: string) => (tty ? `\x1b[1m${s}\x1b[0m` : s) // --------------------------------------------------------------------------- const glob = new Bun.Glob("**/*.test.{ts,tsx}") -const all = (await Array.fromAsync(glob.scan({ cwd: path.join(root, "test") }))).sort() +const all = (await Array.fromAsync(glob.scan({ cwd: path.join(root, "test") }))) + .map((file) => file.replaceAll("\\", "/")) + .sort() export const skipped = new Set([ // Upstream browser OAuth integration tests bind the fixed callback port and diff --git a/packages/opencode/test/kilocode/test-profile.test.ts b/packages/opencode/test/kilocode/test-profile.test.ts index a7b5653f51..c96772d531 100644 --- a/packages/opencode/test/kilocode/test-profile.test.ts +++ b/packages/opencode/test/kilocode/test-profile.test.ts @@ -17,6 +17,17 @@ describe("test profiles", () => { expect(result.files).toContain("kilocode/sessions/remote-sender.test.ts") }) + test("normalizes Windows test paths", () => { + const result = TestProfile.resolve( + "darwin", + all.map((file) => file.replaceAll("/", "\\")), + ) + expect(result.ok).toBe(true) + if (!result.ok) return + expect(result.files).toContain("pty/pty-session.test.ts") + expect(result.files.some((file) => file.includes("\\"))).toBe(false) + }) + test("unknown profiles fail with available names", () => { const result = TestProfile.resolve("unknown", all) expect(result).toEqual({