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>
This commit is contained in:
Hajime Hoshi 2019-08-23 18:54:58 +09:00
parent e8b3e6111d
commit fe31116dde
3 changed files with 11 additions and 6 deletions

View File

@ -225,8 +225,9 @@ func genObjcPackages(t *testing.T, dir string, cg *ObjcWrapper) {
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 @@ func genJavaPackages(t *testing.T, dir string, cg *ClassGen) {
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/...",

View File

@ -37,12 +37,13 @@ func testMain(m *testing.M) int {
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")

View File

@ -47,7 +47,8 @@ func testMain(m *testing.M) int {
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 @@ type Struct struct{
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)
}