TempDirUnixSocket returns a temporary directory that can safely hold unix sockets (probably). During tests on darwin we hit the max path length limit for unix sockets pretty easily in the default location, so this function uses /tmp instead to get shorter paths. On Linux, we also hit this limit on
(t testing.TB)
| 23 | // On Linux, we also hit this limit on GitHub Actions runners where TMPDIR is |
| 24 | // set to a long path like /home/runner/work/_temp/go-tmp/. |
| 25 | func TempDirUnixSocket(t testing.TB) string { |
| 26 | t.Helper() |
| 27 | // Windows doesn't have the same unix socket path length limits, |
| 28 | // and callers of this function are generally gated to !windows. |
| 29 | if runtime.GOOS == "windows" { |
| 30 | return t.TempDir() |
| 31 | } |
| 32 | |
| 33 | testName := strings.ReplaceAll(t.Name(), "/", "_") |
| 34 | dir, err := os.MkdirTemp("/tmp", testName) |
| 35 | require.NoError(t, err, "create temp dir for unix socket test") |
| 36 | |
| 37 | t.Cleanup(func() { |
| 38 | err := os.RemoveAll(dir) |
| 39 | assert.NoError(t, err, "remove temp dir", dir) |
| 40 | }) |
| 41 | return dir |
| 42 | } |
| 43 | |
| 44 | func AgentSocketPath(t testing.TB) string { |
| 45 | if runtime.GOOS == "windows" { |