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

Commit 7d36525

Browse files
authored
Merge pull request #882 from tkrajina/simplify-tests
Simplify temp dir creation in tests
2 parents 6b5e8cf + 39cdb41 commit 7d36525

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

internal/test/integration_testproj.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,7 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru
5050
new.TempDir(ProjectRoot, "vendor")
5151
new.CopyTree(initPath)
5252

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

6455
return new
6556
}
@@ -283,6 +274,12 @@ func (p *IntegrationTestProject) makeRootTempDir() {
283274
var err error
284275
p.tempdir, err = ioutil.TempDir("", "gotest")
285276
p.Must(err)
277+
278+
// Fix for OSX where the tempdir is a symlink:
279+
if runtime.GOOS == "darwin" {
280+
p.tempdir, err = filepath.EvalSymlinks(p.tempdir)
281+
p.Must(err)
282+
}
286283
}
287284
}
288285

@@ -298,15 +295,3 @@ func (p *IntegrationTestProject) Must(err error) {
298295
p.t.Fatalf("%+v", err)
299296
}
300297
}
301-
302-
// Checks for filepath beginnings that result in the "/private" leader
303-
// on Mac platforms
304-
func needsPrivateLeader(path string) bool {
305-
var roots = []string{"/var", "/tmp", "/etc"}
306-
for _, root := range roots {
307-
if strings.HasPrefix(path, root) {
308-
return true
309-
}
310-
}
311-
return false
312-
}

0 commit comments

Comments
 (0)