aboutsummaryrefslogtreecommitdiff
path: root/src/internal/testenv
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2016-03-30 15:13:26 +1100
committerBrad Fitzpatrick <bradfitz@golang.org>2016-03-30 19:12:50 +0000
commitca72f5f5df62181cfc8043e9064b4f847527ec2a (patch)
tree450437f686ffee6f263f64432c665f16cb9e3b3d /src/internal/testenv
parent788f11263a0eccb25d9067525d84208058000391 (diff)
downloadgo-ca72f5f5df62181cfc8043e9064b4f847527ec2a.tar.xz
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
Diffstat (limited to 'src/internal/testenv')
-rw-r--r--src/internal/testenv/testenv.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index cd3f43640a..e751e0cf11 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -13,6 +13,7 @@ package testenv
import (
"os"
"os/exec"
+ "path/filepath"
"runtime"
"strings"
"testing"
@@ -68,10 +69,17 @@ func MustHaveGoRun(t *testing.T) {
// If the tool should be available and isn't, GoToolPath calls t.Fatal.
func GoToolPath(t *testing.T) string {
MustHaveGoBuild(t)
+
var exeSuffix string
if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
+
+ path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
+ if _, err := os.Stat(path); err == nil {
+ return path
+ }
+
goBin, err := exec.LookPath("go" + exeSuffix)
if err != nil {
t.Fatalf("cannot find go tool: %v", err)