]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testshared: explicitly set GOBIN (instead of unsetting it)
authorBryan C. Mills <bcmills@google.com>
Mon, 24 Feb 2020 18:58:29 +0000 (13:58 -0500)
committerBryan C. Mills <bcmills@google.com>
Mon, 24 Feb 2020 20:47:43 +0000 (20:47 +0000)
If GOBIN is set in the GOENV file, then merely unsetting it in the
process environment is not sufficient. We can instead either set GOBIN
explicitly, or disable GOENV explicitly. For now, we (semi-arbitrary)
choose the former.

Fixes #37390

Change-Id: Iec54532c804b70546d695105cd89e9169eac5dbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/220652
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/testshared/shared_test.go

index b9ef6dad8e24cb7c6a21bd84106ba92ee3c30a3a..c7f15b8e8916f6fd142d25b024a5e3ab067d139d 100644 (file)
@@ -105,6 +105,8 @@ func testMain(m *testing.M) (int, error) {
                fmt.Printf("+ cd %s\n", modRoot)
        }
        os.Setenv("GOPATH", gopath)
+       // Explicitly override GOBIN as well, in case it was set through a GOENV file.
+       os.Setenv("GOBIN", filepath.Join(gopath, "bin"))
        os.Chdir(modRoot)
        os.Setenv("PWD", modRoot)
 
@@ -153,10 +155,6 @@ func TestMain(m *testing.M) {
        log.SetFlags(log.Lshortfile)
        flag.Parse()
 
-       // Some of the tests install binaries into a custom GOPATH.
-       // That won't work if GOBIN is set.
-       os.Unsetenv("GOBIN")
-
        exitCode, err := testMain(m)
        if err != nil {
                log.Fatal(err)