Skip to content

Commit 6adb476

Browse files
anandgupta42claude
andcommitted
test: fix Windows CI failures in install and bridge tests
- Replace `/bin/echo` with `process.execPath` in bridge test — /bin/echo does not exist on Windows, causing ENOENT on spawn; process.execPath (the current Bun binary) exists on all platforms and exits quickly without speaking JSON-RPC as expected - Add `unixtest` guard to postinstall, bin-wrapper, and integration tests — on Windows, postinstall.mjs takes a different early-exit path that skips hard-link setup; dummy binaries are Unix shell scripts that cannot be executed on Windows; skip all Unix-specific test paths using the same `process.platform !== "win32" ? test : test.skip` pattern already used in fsmonitor.test.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ff9ea7 commit 6adb476

4 files changed

Lines changed: 31 additions & 16 deletions

File tree

packages/opencode/test/bridge/client.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ describe("Bridge.start integration", () => {
140140
test("ensureEngine is called when bridge starts", async () => {
141141
const { Bridge } = await import("../../src/altimate/bridge/client")
142142

143-
// /bin/echo exists and will spawn successfully but won't respond to
144-
// the JSON-RPC ping, so start() will eventually fail on verification.
145-
process.env.OPENCODE_PYTHON = "/bin/echo"
143+
// process.execPath (the current Bun/Node binary) exists on all platforms.
144+
// When spawned as a Python replacement it exits quickly without speaking
145+
// JSON-RPC, so start() fails on the ping verification as expected.
146+
process.env.OPENCODE_PYTHON = process.execPath
146147

147148
try {
148149
await Bridge.call("ping", {} as any)

packages/opencode/test/install/bin-wrapper.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import {
1111
CURRENT_ARCH,
1212
} from "./fixture"
1313

14+
// Dummy binaries created by the fixture are Unix shell scripts (#!/bin/sh).
15+
// Tests that run these binaries can only pass on Unix platforms.
16+
const unixtest = process.platform !== "win32" ? test : test.skip
17+
1418
let cleanup: (() => void) | undefined
1519

1620
afterEach(() => {
@@ -27,7 +31,7 @@ function copyBinWrapper(destDir: string): string {
2731
}
2832

2933
describe("bin/altimate-code wrapper", () => {
30-
test("uses ALTIMATE_CODE_BIN_PATH env var when set", () => {
34+
unixtest("uses ALTIMATE_CODE_BIN_PATH env var when set", () => {
3135
const { dir, cleanup: c } = installTmpdir()
3236
cleanup = c
3337

@@ -41,7 +45,7 @@ describe("bin/altimate-code wrapper", () => {
4145
expect(result.stdout).toContain("altimate-code-test-ok")
4246
})
4347

44-
test("uses cached .opencode when present", () => {
48+
unixtest("uses cached .opencode when present", () => {
4549
const { dir, cleanup: c } = installTmpdir()
4650
cleanup = c
4751

@@ -54,7 +58,7 @@ describe("bin/altimate-code wrapper", () => {
5458
expect(result.stdout).toContain("altimate-code-test-ok")
5559
})
5660

57-
test("finds binary in sibling node_modules package", () => {
61+
unixtest("finds binary in sibling node_modules package", () => {
5862
const { dir, cleanup: c } = installTmpdir()
5963
cleanup = c
6064

@@ -73,7 +77,7 @@ describe("bin/altimate-code wrapper", () => {
7377
expect(result.stdout).toContain("altimate-code-test-ok")
7478
})
7579

76-
test("finds binary in parent node_modules (hoisted)", () => {
80+
unixtest("finds binary in parent node_modules (hoisted)", () => {
7781
const { dir, cleanup: c } = installTmpdir()
7882
cleanup = c
7983

packages/opencode/test/install/integration.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import {
1111
CURRENT_PLATFORM,
1212
} from "./fixture"
1313

14+
// These integration tests combine postinstall (Unix hard-link path) with
15+
// bin-wrapper execution of a Unix shell-script dummy binary. Skip on Windows
16+
// where both behave differently.
17+
const unixtest = process.platform !== "win32" ? test : test.skip
18+
1419
let cleanup: (() => void) | undefined
1520

1621
afterEach(() => {
@@ -19,7 +24,7 @@ afterEach(() => {
1924
})
2025

2126
describe("install pipeline integration", () => {
22-
test("full flow: layout -> postinstall -> bin wrapper executes dummy binary", () => {
27+
unixtest("full flow: layout -> postinstall -> bin wrapper executes dummy binary", () => {
2328
const { dir, cleanup: c } = installTmpdir()
2429
cleanup = c
2530

@@ -44,7 +49,7 @@ describe("install pipeline integration", () => {
4449
expect(wrapperResult.stdout).toContain("altimate-code-test-ok")
4550
})
4651

47-
test("missing optional dep: postinstall fails, bin wrapper also fails gracefully", () => {
52+
unixtest("missing optional dep: postinstall fails, bin wrapper also fails gracefully", () => {
4853
const { dir, cleanup: c } = installTmpdir()
4954
cleanup = c
5055

@@ -70,7 +75,7 @@ describe("install pipeline integration", () => {
7075
expect(wrapperResult.stderr).toContain("package manager failed to install")
7176
})
7277

73-
test("wrong-platform-only install: both scripts fail with clear errors", () => {
78+
unixtest("wrong-platform-only install: both scripts fail with clear errors", () => {
7479
const { dir, cleanup: c } = installTmpdir()
7580
cleanup = c
7681

packages/opencode/test/install/postinstall.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
CURRENT_PLATFORM,
1010
} from "./fixture"
1111

12+
// On Windows, postinstall.mjs takes a different early-exit path that skips
13+
// binary setup entirely (the .exe is packaged separately). Skip all tests that
14+
// depend on the Unix hard-link / error-path behavior.
15+
const unixtest = process.platform !== "win32" ? test : test.skip
16+
1217
let cleanup: (() => void) | undefined
1318

1419
afterEach(() => {
@@ -17,7 +22,7 @@ afterEach(() => {
1722
})
1823

1924
describe("postinstall.mjs", () => {
20-
test("finds binary and creates hard link in bin/", () => {
25+
unixtest("finds binary and creates hard link in bin/", () => {
2126
const { dir, cleanup: c } = installTmpdir()
2227
cleanup = c
2328

@@ -34,7 +39,7 @@ describe("postinstall.mjs", () => {
3439
expect(stat.mode & 0o111).toBeGreaterThan(0)
3540
})
3641

37-
test("replaces existing stale binary", () => {
42+
unixtest("replaces existing stale binary", () => {
3843
const { dir, cleanup: c } = installTmpdir()
3944
cleanup = c
4045

@@ -54,7 +59,7 @@ describe("postinstall.mjs", () => {
5459
expect(content).toContain("altimate-code-test-ok")
5560
})
5661

57-
test("creates bin/ dir if missing", () => {
62+
unixtest("creates bin/ dir if missing", () => {
5863
const { dir, cleanup: c } = installTmpdir()
5964
cleanup = c
6065

@@ -84,7 +89,7 @@ describe("postinstall.mjs", () => {
8489
expect(result.stdout).toContain("altimate-code v2.5.0 installed")
8590
})
8691

87-
test("exits 1 when platform binary package is missing", () => {
92+
unixtest("exits 1 when platform binary package is missing", () => {
8893
const { dir, cleanup: c } = installTmpdir()
8994
cleanup = c
9095

@@ -96,7 +101,7 @@ describe("postinstall.mjs", () => {
96101
expect(result.stderr).toContain("Failed to setup altimate-code binary")
97102
})
98103

99-
test("exits 1 when package exists but binary file is missing", () => {
104+
unixtest("exits 1 when package exists but binary file is missing", () => {
100105
const { dir, cleanup: c } = installTmpdir()
101106
cleanup = c
102107

@@ -108,7 +113,7 @@ describe("postinstall.mjs", () => {
108113
expect(result.stderr).toContain("Failed to setup altimate-code binary")
109114
})
110115

111-
test("exits 1 when only wrong-platform package is present", () => {
116+
unixtest("exits 1 when only wrong-platform package is present", () => {
112117
const { dir, cleanup: c } = installTmpdir()
113118
cleanup = c
114119

0 commit comments

Comments
 (0)