Commit 1a6fd7f
test: isolate terminalProxyFactory mock leak; disable skipMatchingPatterns in test runner (#140)
## Summary
Two latent test fragilities, both invisible on CI and on most
contributors' machines but reproducible from a working tree under `/tmp`
or `/var/folders` (worktrees, scratch clones, some CI configs).
- `logPoller.test.ts` builds project paths from `process.cwd()`. The
default `config.skipMatchingPatterns` (`src/server/config.ts:65-71`)
matches `/private/tmp/*`, `/tmp/*`, `/private/var/folders/*`,
`/var/folders/*` — exactly where tmp-rooted checkouts live. The matcher
then skips those projects, so the orphan-rematch tests silently fail
(e.g. `rematches orphaned sessions on startup without new activity`,
`clears resume error when orphaned session rematches during poll`). The
patterns are a production safety net; they shouldn't gate test fixtures.
- `terminalProxyFactory.test.ts:42-44` installs a top-level
`mock.module('../config', ...)` whose replacement omits many real-config
fields. Bun's `mock.restore()` in `afterAll` does not fully unwind
module-level mocks, so later files that import `../config` read through
the stripped mock. On many readdir orderings this happened to mask issue
(1) above — the stripped config has no skip patterns, so the
orphan-rematch tests "passed" via mock leakage instead of legitimately.
## Fix
- Set `AGENTBOARD_SKIP_MATCHING_PATTERNS=''` in the runner's subprocess
env so the matcher doesn't suppress test working directories.
- Add `terminalProxyFactory.test.ts` to `ISOLATED_FILES` so it runs in
its own bun process and can't bleed module mocks into later files.
## Test plan
- [x] `bun run lint` — clean
- [x] `bun run typecheck` — clean
- [x] `bun run test` from `/Users/garybasin/Code/agentboard` — all green
- [x] `bun run test` from `/tmp/test-fixes` worktree (the
previously-failing case) — all green
- [x] No production source code changed; only `scripts/test-runner.ts`.
## Notes
- Tests that intentionally exercise skip-pattern logic
(`logMatchGate.test.ts`) pass patterns directly to the matcher API, so
they are unaffected.
- Direct `bun test <file>` invocations from a `/tmp`-rooted checkout
still skip — only `bun run test` (the documented entry point and what
CI/hooks use) is wired up. Adding the env wiring at the `bun test` layer
would require either Bun's `preload` mechanism or every test file
setting its own env, both of which are heavier than warranted here.
---------
Co-authored-by: Gary Basin <gary@pineapple.mortgage>1 parent 7cbda40 commit 1a6fd7f
1 file changed
Lines changed: 30 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
58 | 71 | | |
59 | 72 | | |
60 | 73 | | |
| |||
90 | 103 | | |
91 | 104 | | |
92 | 105 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
100 | 117 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
108 | 124 | | |
109 | 125 | | |
110 | 126 | | |
| |||
0 commit comments