From a1ec9df3458667079c2f9e02aa7608d166ec5d67 Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:06:17 +1000 Subject: [PATCH] test(agent/agentcontext): use resolved temp dirs in symlink tests (#26602) These symlink resolver tests build expected paths from `t.TempDir()`, but the resolver canonicalizes symlink targets with `filepath.EvalSymlinks`. On macOS, `/var` resolves to `/private/var`, so the raw temp dir path can disagree with the resolver output and flake. Use `testutil.TempDirResolved` in the symlink-sensitive tests so the expectations are canonicalized the same way. Closes https://github.com/coder/internal/issues/1574 Closes ENG-2849 --- agent/agentcontext/resolve_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agent/agentcontext/resolve_test.go b/agent/agentcontext/resolve_test.go index 0254a113c4..a8ea63e951 100644 --- a/agent/agentcontext/resolve_test.go +++ b/agent/agentcontext/resolve_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/require" "github.com/coder/coder/v2/agent/agentcontext" + "github.com/coder/coder/v2/testutil" ) func mustWriteFile(t *testing.T, path, content string) { @@ -165,7 +166,7 @@ func TestResolver_SymlinkInsideScanRootAllowed(t *testing.T) { t.Skip("symlinks require admin privileges on Windows runners") } t.Parallel() - dir := t.TempDir() + dir := testutil.TempDirResolved(t) target := filepath.Join(dir, "docs", "AGENTS.md") require.NoError(t, os.MkdirAll(filepath.Dir(target), 0o755)) mustWriteFile(t, target, "shared monorepo guidance") @@ -196,7 +197,7 @@ func TestResolver_SymlinkedInstructionFilesDeduplicated(t *testing.T) { t.Skip("symlinks require admin privileges on Windows runners") } t.Parallel() - dir := t.TempDir() + dir := testutil.TempDirResolved(t) agents := filepath.Join(dir, "AGENTS.md") mustWriteFile(t, agents, "the one true guidance") require.NoError(t, os.Symlink(agents, filepath.Join(dir, "CLAUDE.md")))