Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Merged
Changes from all commits
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
29 changes: 7 additions & 22 deletions internal/test/integration_testproj.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,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 +274,12 @@ func (p *IntegrationTestProject) makeRootTempDir() {
var err error
p.tempdir, err = ioutil.TempDir("", "gotest")
p.Must(err)

// Fix for OSX where the tempdir is a symlink:
if runtime.GOOS == "darwin" {
p.tempdir, err = filepath.EvalSymlinks(p.tempdir)
p.Must(err)
}
}
}

Expand All @@ -298,15 +295,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
}