Repository navigation
test(cmd): tests leave index dirs in the real ~/.local/share/lumen - #197
escooterclinic wants to merge 1 commit into
Conversation
Two cmd tests build an index without setting XDG_DATA_HOME, so every go test ./cmd/ leaves index directories in the developer's real ~/.local/share/lumen. TestMain now points HOME, XDG_DATA_HOME and XDG_CONFIG_HOME at a temp dir for the whole package, and TestSuiteDataDirIsIsolated fails if that redirect is removed.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Run tests with an isolated home cmd/hook_test.go |
TestMain runs the suite through runIsolated, while retaining its early exit for subprocesses invoked with the index argument. runIsolated sets temporary home and XDG paths, then removes the temporary directory. TestSuiteDataDirIsIsolated checks that the data directory is under the suite home. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Other
Suggested reviewers: aeneasr
Merge Risk: 
Minimal · up to addb6
-
The cmd tests resolve index paths under the temporary data directory. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Running
go test ./cmd/on main leaves index directories in the real~/.local/share/lumen. On a machine that also runs Lumen for real, they show up as stale indexes untillumen cleanremoves them. I mentioned the HOME sensitivity of thecmdtests in #195. This is the fix. Tested on main at f60f9ec, macOS.Two tests build an index without setting
XDG_DATA_HOME:TestIndexerCache_ConcurrentReads(a 4-dim index for/nonexistent/path/for/race/test) andTestSetupIndexer_DBPathVsDirectory(a 768-dim one). Pointing HOME andXDG_DATA_HOMEat an empty dir and running the package on main gives two directories underlumen/. With this change it gives none.Rather than patch those two tests,
TestMainnow runs the whole package with HOME,XDG_DATA_HOMEandXDG_CONFIG_HOMEin a temp dir, so the next test that forgets can't leak either. That also stops a developer's own Lumen config and index from leaking into the tests.TestSuiteDataDirIsIsolatedchecks thatconfig.XDGDataDir()resolves under that temp dir, and it fails if the redirect is removed. Tests that set their own env witht.Setenvare unaffected, andgo test ./cmd/is green.The patch and the test were written with a coding agent.
Summary by CodeRabbit