test(cli): make code-pack + setup-scip tests host-agnostic#154
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two
@opencodehub/clitests 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)wherecwdcame frommkdtemp(tmpdir(), ...). On macOStmpdir()returns/tmp/..., but/tmpis a symlink to/private/tmp, so afterprocess.chdir(cwd)the production code resolves againstprocess.cwd()→/private/tmp/.... The assertion compared/private/tmp/...(actual) vs/tmp/...(expected) and failed.→ Read
process.cwd()back afterchdirand 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'sdetectPlatform()found no matching platform entry, installed 0 tools, andresult.installed.lengthwas0 !== 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
maincheckout in a macOS sandbox (verified against the cleanorigin/mainworktree). They're invisible in CI (Linux, no/tmpsymlink, host is linux-x64), so they only bite local Mac development. This removes the host assumption.Verification
pnpm --filter @opencodehub/cli test— 256/256 pass (was 254 pass / 2 fail)pnpm -r testrecursive + typecheck + verdict) — greenTest plan
detectPlatform()