Commit 64968e5
authored
test(cli): make code-pack + setup-scip tests host-agnostic (#154)
## 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 test` — **256/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
- [x] Both tests pass on macOS arm64
- [x] Logic preserves the linux-x64 path (CI host) via
`detectPlatform()`
- [x] No production code touched1 parent 7d0c41b commit 64968e5
2 files changed
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | | - | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
160 | | - | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
442 | 447 | | |
443 | 448 | | |
444 | 449 | | |
445 | 450 | | |
446 | 451 | | |
447 | 452 | | |
448 | 453 | | |
449 | | - | |
| 454 | + | |
450 | 455 | | |
451 | 456 | | |
452 | 457 | | |
| |||
462 | 467 | | |
463 | 468 | | |
464 | 469 | | |
465 | | - | |
466 | | - | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
| |||
0 commit comments