Skip to content

internal/cli path-containment tests fail on macOS (/var vs /private/var symlink) #2962

Description

@dhshah13

`TestResolveAgentSource_ConfigLocalPath`, `TestContainedLocalPath_Valid`, and `TestContainedLocalPath_DotSegmentsCleaned` in `internal/cli/run_test.go` fail on macOS on a clean checkout of `main`.

`containedLocalPath` returns the `filepath.EvalSymlinks`-resolved path (symlink-escape containment check, introduced in #2769). On macOS `t.TempDir()` lives under `/var/folders/...` and `/var` is a symlink to `/private/var`, so the returned path is canonicalized to `/private/var/...` while the tests build the expected path from the raw `t.TempDir()` value:

expected: "/var/folders/.../TestContainedLocalPath_Valid.../001/harness/agent.yaml"
actual  : "/private/var/folders/.../TestContainedLocalPath_Valid.../001/harness/agent.yaml"

CI runs `internal/cli` tests on Linux only, so this never surfaces there. Locally on macOS it makes every `go test ./internal/cli/` run red, masking real failures.

Repro (macOS):

go test -run 'TestResolveAgentSource_ConfigLocalPath|TestContainedLocalPath' ./internal/cli/

Fix: canonicalize the temp dir with `filepath.EvalSymlinks` in the affected tests so expected and actual agree. The production behavior is correct and unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions