Skip to content

Commit ca72f5f

Browse files
committed
internal/testenv: prefer to find go binary in GOROOT
Partial revert of https://golang.org/cl/20967 which I can't reproduce and actually breaks me more. Fixes #14901 Change-Id: I8cce443fbd95f5f6f2a5b6a4b9f2faab36167a12 Reviewed-on: https://go-review.googlesource.com/21292 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: David Crawshaw <[email protected]>
1 parent 788f112 commit ca72f5f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/internal/testenv/testenv.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package testenv
1313
import (
1414
"os"
1515
"os/exec"
16+
"path/filepath"
1617
"runtime"
1718
"strings"
1819
"testing"
@@ -68,10 +69,17 @@ func MustHaveGoRun(t *testing.T) {
6869
// If the tool should be available and isn't, GoToolPath calls t.Fatal.
6970
func GoToolPath(t *testing.T) string {
7071
MustHaveGoBuild(t)
72+
7173
var exeSuffix string
7274
if runtime.GOOS == "windows" {
7375
exeSuffix = ".exe"
7476
}
77+
78+
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
79+
if _, err := os.Stat(path); err == nil {
80+
return path
81+
}
82+
7583
goBin, err := exec.LookPath("go" + exeSuffix)
7684
if err != nil {
7785
t.Fatalf("cannot find go tool: %v", err)

0 commit comments

Comments
 (0)