Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 4811b1b

Browse files
author
tro3
committed
Adding darwin leader check and documentation
1 parent 6de6c77 commit 4811b1b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/integration_testproj.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ func NewTestProject(t *testing.T, initPath, wd string) *IntegrationTestProject {
4545
new.makeRootTempDir()
4646
new.TempDir(ProjectRoot, "vendor")
4747
new.CopyTree(initPath)
48-
if runtime.GOOS == "darwin" {
48+
49+
// Note that the Travis darwin platform, directories with certain roots such
50+
// as /var are actually links to a dirtree under /private. Without the patch
51+
// below the wd, and therefore the GOPATH, is recorded as "/var/..." but the
52+
// actual process runs in "/private/var/..." and dies due to not being in the
53+
// GOPATH because the roots don't line up.
54+
if runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) {
4955
new.Setenv("GOPATH", filepath.Join("/private", new.tempdir))
5056
} else {
5157
new.Setenv("GOPATH", new.tempdir)
5258
}
59+
5360
return new
5461
}
5562

@@ -283,3 +290,15 @@ func (p *IntegrationTestProject) Must(err error) {
283290
p.t.Fatalf("%+v", err)
284291
}
285292
}
293+
294+
// Checks for filepath beginnings that result in the "/private" leader
295+
// on Mac platforms
296+
func needsPrivateLeader(path string) bool {
297+
var roots = []string{"/var", "/tmp", "/etc"}
298+
for _, root := range roots {
299+
if strings.HasPrefix(path, root) {
300+
return true
301+
}
302+
}
303+
return false
304+
}

0 commit comments

Comments
 (0)