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
This commit is contained in:
Ethan
2026-06-23 06:06:17 +00:00
committed by GitHub
parent e88f2a3485
commit a1ec9df345
+3 -2
View File
@@ -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")))