You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f57de29
Browse filesBrowse the repository at this point in the historyBrowse files
Token Goat Test
committed
test: stop the stored-chunk-cap test writing the worker-shared config
The test set `max_chunks_per_file = 6` by writing `configPath()`, which
`tests/setup/isolate-home.ts` pins once per Vitest worker rather than per
file. Every other file that worker runs reads that same config, so a cap of
6 was observable outside the test that set it -- including by the three
suites whose `beforeAll` walks and embeds the whole `src` tree.
It restored the previous contents in `afterEach`, so nothing had actually
been observed failing because of it; a worker killed mid-test would have
left the cap behind. The hazard is the same one recorded at the head of
`tests/cache_session_commands.test.ts`, where mutating one unrelated field
of the shared config broke a test further down that file.
Redirected to a per-file temp path with the established
`vi.mock('../src/constants.js')` plus `tempConfigPath()` pattern. Proven by
pinning `TOKEN_GOAT_HOME` at an empty directory and running the file: no
`config.toml` appears there now. The save/restore is gone with it, since
`tempConfigPath` roots are removed when the process exits and no other file
can observe the path.
// Redirects configPath() to a per-test-FILE temp file. tests/setup/isolate-home.ts pins TOKEN_GOAT_HOME once per Vitest worker, so the real config.toml is shared by every test file that worker runs, and this file rewrites `max_chunks_per_file` in beforeEach: any file sharing the worker would read a cap of 6 mid-run, including the ones whose beforeAll walks and embeds the whole src tree. The same hazard is documented at the head of tests/cache_session_commands.test.ts, where mutating one unrelated field of the shared config broke a test further down that same file.
// loadConfig keys its cache on a content hash of this file, so writing it is enough to invalidate; the assertion in each test confirms the value really took effect rather than assuming it. TOKEN_GOAT_HOME is isolated for the run by tests/setup/isolate-home.ts, so this is not a real ~/.token-goat, but it IS shared with other test files in the same run -- hence the restore in afterEach.
103
+
// loadConfig keys its cache on a content hash of this file, so writing it is enough to invalidate; the assertion in each test confirms the value really took effect rather than assuming it. The path is this file's own, per the vi.mock at the head, so there is nothing to save and restore: no other test file can observe it, and tempConfigPath's root is removed when the process exits.
0 commit comments