Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions internal/test/integration_testproj.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -50,16 +49,7 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru
new.TempDir(ProjectRoot, "vendor")
new.CopyTree(initPath)

// Note that the Travis darwin platform, directories with certain roots such
// as /var are actually links to a dirtree under /private. Without the patch
// below the wd, and therefore the GOPATH, is recorded as "/var/..." but the
// actual process runs in "/private/var/..." and dies due to not being in the
// GOPATH because the roots don't line up.
if externalProc && runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) {
new.Setenv("GOPATH", filepath.Join("/private", new.tempdir))
} else {
new.Setenv("GOPATH", new.tempdir)
}
new.Setenv("GOPATH", new.tempdir)

return new
}
Expand Down Expand Up @@ -283,6 +273,10 @@ func (p *IntegrationTestProject) makeRootTempDir() {
var err error
p.tempdir, err = ioutil.TempDir("", "gotest")
p.Must(err)

// Fox for OSX where the tempdir is a symlink:
p.tempdir, err = filepath.EvalSymlinks(p.tempdir)
p.Must(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not wrap this in if runtime.GOOS == "darwin" { ... }?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...for a hypothetical new OS/platform which also creates temp files as symlinks? :)

PS. Added now.

}
}

Expand All @@ -298,15 +292,3 @@ func (p *IntegrationTestProject) Must(err error) {
p.t.Fatalf("%+v", err)
}
}

// Checks for filepath beginnings that result in the "/private" leader
// on Mac platforms
func needsPrivateLeader(path string) bool {
var roots = []string{"/var", "/tmp", "/etc"}
for _, root := range roots {
if strings.HasPrefix(path, root) {
return true
}
}
return false
}