Skip to content

test: never write the real user state dirs from tests - #138

Merged
mlhher merged 2 commits into
mlhher:mainfrom
Emasoft:test/isolate-user-dirs
Sep 24, 2026
Merged

mlhher merged 2 commits into
mlhher:mainfrom
Emasoft:test/isolate-user-dirs

Conversation

@Emasoft

@Emasoft Emasoft commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Several tests were quietly writing to the real user state dirs: session-meta sidecars landed in ~/.local/share/late/sessions, and plugin management tests rewrote the global plugins.json under ~/Library/Application Support/late. This branch redirects all of them to temp dirs, so the suite provably writes nothing there.

  • Session-meta sidecars — 10 test functions (agent/orchestrator/executor) that spawn subagents or commit turns now point the session layer's global SessionDir at t.TempDir(). Production meta placement is unchanged (the --continue lister depends on it).
  • Global plugin state — 10 test functions (link/install/enable/disable/remove flows) now run under the package's sandboxUserConfig convention, so plugins.json is always a throwaway.
  • Test-only: no new tests, no production changes.

Note: the sibling feature PRs split from the same upstream base and don't carry these redirects — this branch holds the full isolation set on its own.

Testing

Full suite run against the real home with before/after sentinels on both state dirs:

$ go test ./... -race -count=1
ok  	late/cmd/late	2.430s
?   	late/cmd/mcp-run	[no test files]
ok  	late/internal/agent	4.504s
?   	late/internal/assets	[no test files]
ok  	late/internal/client	1.446s
ok  	late/internal/common	2.954s
ok  	late/internal/config	2.886s
ok  	late/internal/executor	9.911s
ok  	late/internal/git	2.873s
ok  	late/internal/mcp	1.778s
ok  	late/internal/orchestrator	4.893s
?   	late/internal/pathutil	[no test files]
ok  	late/internal/plugin	14.225s
ok  	late/internal/session	3.651s
ok  	late/internal/skill	4.424s
ok  	late/internal/tool	1.806s
ok  	late/internal/tool/ast	4.551s
ok  	late/internal/tui	10.671s

exit 0 — all 18 packages green (15 ok, 3 without test files).

Proof of no user-dir writes:

$ find ~/.local/share/late ~/Library/Application\ Support/late -type f -newer <pre-test sentinel>
(no output)

newer-count: 0
  • Full path+mtime+size listing of both dirs: 499 files before, 499 after, diff empty (tree identical)

  • config.json sha256 before and after: 70fa8c8f7fc750b18b9de0513adf599ca2f766d9ac5ebeca51edcc25267eb2a9 (unchanged)

  • gofmt -l on the touched files: no output (clean)

  • go vet ./internal/agent ./internal/executor ./internal/orchestrator ./internal/plugin: clean

13 tests in executor/orchestrator/agent wrote *.meta.json sidecars into
the real ~/.local/share/late/sessions via the global SessionDir; all now
redirect it to t.TempDir(). Production meta placement is unchanged (the
resume lister depends on it).
…gin state file

10 plugin tests rewrote the real ~/Library/Application Support/late/
plugins.json; they now run under the package's sandboxUserConfig
convention so the full suite provably writes nothing outside temp dirs.
@mlhher

mlhher commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Thank you for splitting the PRs that will allow going far quicker at them.

@mlhher
mlhher merged commit babdf18 into mlhher:main Sep 24, 2026
1 check passed
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.

2 participants