test: fix TestWatcher_SharedParentRefcount on macOS#25379
Merged
Conversation
27aad6f to
868c81e
Compare
On macOS, t.TempDir() lives under /var which is a symlink to /private/var. The watcher canonicalizes paths via filepath.EvalSymlinks before storing them in w.dirs, so the assertion w.dirs[dir] returned 0 instead of the expected 2 on macOS runners. Introduce testutil.TempDirResolved as a shared helper that returns t.TempDir() with symlinks resolved, falling back to the raw temp dir if EvalSymlinks errors (e.g. on Windows). Migrate the matching inline EvalSymlinks(t.TempDir()) callsites in agent/agentgit/agentgit_test.go to use it. Closes coder/internal#1531
868c81e to
ef50e80
Compare
ThomasK33
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestWatcher_SharedParentRefcountwas deterministically broken on macOS:t.TempDir()lives under/varwhich is a symlink to/private/var, but the watcher canonicalizes paths viafilepath.EvalSymlinksbefore storing them, so the test'sw.dirs[dir]lookup missed and returned0instead of2.Adds
testutil.TempDirResolved, a shared helper that returnst.TempDir()with symlinks resolved and falls back to the raw temp dir on error (Windows-friendly). Migrates the matching inlineEvalSymlinks(t.TempDir())callsites inagent/agentgit/agentgit_test.goto use it.Closes coder/internal#1531