Skip to content

test(cli): make code-pack + setup-scip tests host-agnostic#154

Merged
theagenticguy merged 1 commit into
mainfrom
fix/brittle-cli-tests-env
May 29, 2026
Merged

test(cli): make code-pack + setup-scip tests host-agnostic#154
theagenticguy merged 1 commit into
mainfrom
fix/brittle-cli-tests-env

Conversation

@theagenticguy

Copy link
Copy Markdown
Owner

Summary

Two @opencodehub/cli tests baked in host-environment assumptions and failed on macOS (they pass on Linux CI, so they were latent). Surfaced while validating an unrelated dep bump on a Mac. Test-only — no production code changes.

The two fixes

1. code-pack — "resolves a relative repo path against process.cwd()"
The test asserted opts.repoPath === resolve(cwd) where cwd came from mkdtemp(tmpdir(), ...). On macOS tmpdir() returns /tmp/..., but /tmp is a symlink to /private/tmp, so after process.chdir(cwd) the production code resolves against process.cwd()/private/tmp/.... The assertion compared /private/tmp/... (actual) vs /tmp/... (expected) and failed.
→ Read process.cwd() back after chdir and assert against that — exactly what the production code sees.

2. setup-scip — "installs a single tool via injected fetch + allowPlaceholder"
The test hard-coded a { os: "linux", arch: "x64" } platform pin (comment even said "the test runs on AL2023 which is already linux-x64"). On darwin/arm64 the downloader's detectPlatform() found no matching platform entry, installed 0 tools, and result.installed.length was 0 !== 1.
→ Build the pin from detectPlatform() so it matches whatever host runs the test — linux-x64 in CI, darwin-arm64 on a dev Mac.

Why now

Both failures reproduce on a clean main checkout in a macOS sandbox (verified against the clean origin/main worktree). They're invisible in CI (Linux, no /tmp symlink, host is linux-x64), so they only bite local Mac development. This removes the host assumption.

Verification

  • pnpm --filter @opencodehub/cli test256/256 pass (was 254 pass / 2 fail)
  • Full pre-push gate (pnpm -r test recursive + typecheck + verdict) — green
  • Banned-strings patterns checked manually against the diff (clean); local hook can't run (needs bash 4+, macOS ships 3.2)

Test plan

  • Both tests pass on macOS arm64
  • Logic preserves the linux-x64 path (CI host) via detectPlatform()
  • No production code touched

Two cli tests assumed a specific host environment and failed on macOS:

- code-pack 'resolves relative repo path against process.cwd()' asserted
  against the raw mkdtemp string, but macOS resolves /tmp -> /private/tmp,
  so process.cwd() (and the production code) returns the realpath form.
  Assert against process.cwd() read back after chdir.
- setup-scip 'installs a single tool via injected fetch' hard-coded a
  linux/x64 platform pin, so the downloader matched nothing on darwin/arm64
  and installed 0 tools (0 != 1). Build the pin from detectPlatform() so it
  matches whatever host runs the test (linux-x64 in CI, darwin-arm64 locally).

Both failures reproduce on a clean main checkout in this environment; this
removes the host assumption. No production code changes.
@theagenticguy
theagenticguy merged commit 64968e5 into main May 29, 2026
41 of 45 checks passed
@theagenticguy
theagenticguy deleted the fix/brittle-cli-tests-env branch May 29, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant