all: use GOROOT/bin/go instead of go for tests

Using 'go' command in tests is confusing when using a different version
of Go (e.g., go1.13rc1). Use GOROOT/bin/go so that the same Go is used.

Change-Id: I0ca297207acc5e7fd8b291f544302f6c7b0d38e1
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/191517
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/bind/bind_test.go b/bind/bind_test.go
index 73a34c9..dd8ad32 100644
--- a/bind/bind_test.go
+++ b/bind/bind_test.go
@@ -225,8 +225,9 @@
 		t.Fatal(err)
 	}
 
+	gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
 	cmd := exec.Command(
-		"go",
+		gocmd,
 		"install",
 		"-pkgdir="+filepath.Join(dir, "pkg", build.Default.GOOS+"_"+build.Default.GOARCH),
 		"ObjC/...",
@@ -266,8 +267,9 @@
 	io.Copy(buf, cg.Buf)
 	cg.Buf = buf
 
+	gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
 	cmd := exec.Command(
-		"go",
+		gocmd,
 		"install",
 		"-pkgdir="+filepath.Join(dir, "pkg", build.Default.GOOS+"_"+build.Default.GOARCH),
 		"Java/...",
diff --git a/bind/java/seq_test.go b/bind/java/seq_test.go
index 5ac8c1f..fc1575c 100644
--- a/bind/java/seq_test.go
+++ b/bind/java/seq_test.go
@@ -37,12 +37,13 @@
 		exe = ".exe"
 	}
 	if runtime.GOOS != "android" {
+		gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
 		gomobileBin = filepath.Join(binDir, "gomobile"+exe)
 		gobindBin := filepath.Join(binDir, "gobind"+exe)
-		if out, err := exec.Command("go", "build", "-o", gomobileBin, "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
+		if out, err := exec.Command(gocmd, "build", "-o", gomobileBin, "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
 			log.Fatalf("gomobile build failed: %v: %s", err, out)
 		}
-		if out, err := exec.Command("go", "build", "-o", gobindBin, "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
+		if out, err := exec.Command(gocmd, "build", "-o", gobindBin, "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
 			log.Fatalf("gobind build failed: %v: %s", err, out)
 		}
 		PATH := os.Getenv("PATH")
diff --git a/cmd/gobind/gobind_test.go b/cmd/gobind/gobind_test.go
index 7cdae3d..e3d1351 100644
--- a/cmd/gobind/gobind_test.go
+++ b/cmd/gobind/gobind_test.go
@@ -47,7 +47,8 @@
 	bin.Close()
 	defer os.Remove(bin.Name())
 	if runtime.GOOS != "android" {
-		if out, err := exec.Command("go", "build", "-o", bin.Name(), "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
+		gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
+		if out, err := exec.Command(gocmd, "build", "-o", bin.Name(), "golang.org/x/mobile/cmd/gobind").CombinedOutput(); err != nil {
 			log.Fatalf("gobind build failed: %v: %s", err, out)
 		}
 		gobindBin = bin.Name()
@@ -109,7 +110,8 @@
 		t.Fatal(err)
 	}
 
-	gopath, err := exec.Command("go", "env", "GOPATH").Output()
+	gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
+	gopath, err := exec.Command(gocmd, "env", "GOPATH").Output()
 	if err != nil {
 		t.Fatal(err)
 	}