Skip to content

fix(#402): home.Dir never answers ~/.aforge under go test - #827

Merged
santoshkumarradha merged 1 commit into
devfrom
santosh/fix-402-home-dir-test-isolation-ccc5
Sep 10, 2026
Merged

santoshkumarradha merged 1 commit into
devfrom
santosh/fix-402-home-dir-test-isolation-ccc5

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

Summary

Closes #402. Under go test, home.Dir() no longer falls back to the owner’s ~/.aforge, so a package that forgets to pin a home cannot write into live profile state.

Change

  • In a test binary, if the resolved root is the one the process inherited, home.Dir() returns a per-PID throwaway (/tmp/aforge-test-home-<pid>).
  • A root a test chose (t.Setenv / moved HOME) still wins.
  • home.InheritedDir() is the ungated door for the few places that intentionally need the person’s root (session journal-growth guard, e2e credential copy).

Same shape as the existing lane/calllog undertest gates: one resolution seam, not every TestMain.

Verification (light)

  • go test -count=1 ./internal/home/ pass
  • go test ./internal/lane/ isolation tests pass
  • e2e harness compiles with InheritedDir
  • changelog check pass

Heavy suites not run in cloud — please verify locally.

Open in Web Open in Cursor 

A test package that forgot to pin AFORGE_HOME resolved the live state
root, so journals, caches and the profile of whoever ran the suite were
writable. The gate is on Dir itself: an inherited root becomes a
per-process throwaway, a root the test chose still wins, and
InheritedDir is the one door for the session guard and the e2e
credential copy.

Co-authored-by: Santosh kumar <[email protected]>
@santoshkumarradha
santoshkumarradha force-pushed the santosh/fix-402-home-dir-test-isolation-ccc5 branch from 6389dbc to f535f03 Compare September 10, 2026 22:51
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review September 10, 2026 22:51
@santoshkumarradha
santoshkumarradha merged commit d1d8028 into dev Sep 10, 2026
2 checks passed
@santoshkumarradha
santoshkumarradha deleted the santosh/fix-402-home-dir-test-isolation-ccc5 branch September 10, 2026 22:51
@santoshkumarradha santoshkumarradha added the bug Something the code does that it should not label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something the code does that it should not

Projects

None yet

2 participants