Skip to content

test: every test gets its own HOME, so none write the real ~/.cache - #298

Merged
AltDoug merged 2 commits into
mainfrom
test/isolate-home
Oct 30, 2026
Merged

AltDoug merged 2 commits into
mainfrom
test/isolate-home

Conversation

@AltDoug

@AltDoug AltDoug commented Oct 30, 2026

Copy link
Copy Markdown
Owner

What

  • tests/helpers.bash: HOME is the test's own $BATS_TEST_TMPDIR/home, with a .gitconfig holding the test identity; XDG_CACHE_HOME / XDG_CONFIG_HOME / XDG_DATA_HOME / XDG_STATE_HOME are unset. Tests that set their own HOME are unchanged.
  • New tests/test-isolation.bats (3 tests). README test count 2055 → 2058.

Why

Ledger tests/helpers.bash:25: tests that kept the real HOME wrote the CLI's caches into the operator's ~/.cache/found-issues. Measured 2026-10-29: mode_foo_bar (a fixture slug) was rewritten during a suite run. Under bats --jobs those files were also shared between tests running at the same time.

Evidence

  • tests/test-isolation.bats red before the change: HOME was the real home, and the mode-cache file landed in the real ~/.cache (the test's teardown removed it). Green after.
  • Full suite bats --jobs 14 tests/: 1..2058, 2057 ok, 1 not ok = the README count check, then fixed (tests/docs-consistency.bats + isolation: 17/17).
  • No file in the real ~/.cache/found-issues was newer than a marker touched just before the full run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MVx3HWniZnrXYfPiCo5Lrs

AltDoug and others added 2 commits October 30, 2026 00:32
tests/helpers.bash now points HOME at the test's BATS_TEST_TMPDIR (with a
.gitconfig carrying the test identity) and unsets the XDG dirs. Tests that
kept the real HOME wrote the CLI's caches into the operator's
~/.cache/found-issues (mode_foo_bar rewritten during a suite run,
measured 2026-10-29) and shared them with tests running beside them.

tests/test-isolation.bats: HOME is per test, a real mode-cache write lands
in it and not in the account's home, commits work without fi_init_git.
Red before the change (the leak file appeared in the real cache), green
after. Full parallel suite: 2058 tests, no file in the real
~/.cache/found-issues written during the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MVx3HWniZnrXYfPiCo5Lrs
@AltDoug
AltDoug enabled auto-merge (squash) October 30, 2026 04:32
@AltDoug
AltDoug merged commit 84e67f6 into main Oct 30, 2026
7 checks passed
@AltDoug
AltDoug deleted the test/isolate-home branch October 30, 2026 04:50
AltDoug added a commit that referenced this pull request Oct 30, 2026
Claude-Session: https://claude.ai/code/session_01MVx3HWniZnrXYfPiCo5Lrs

Co-authored-by: Diogo Silva Sena <227921880+DougBTW@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant