1
0
mirror of https://github.com/golang/go synced 2024-11-19 21:14:43 -07:00

cmd/compile: fix test to use correct go binary

Use internal/testenv package to get the right go binary.
Otherwise, I think we're just grabbing an old one from the environment.

Fixes #22560.

Change-Id: Id5b743b24717e15ec8ffbcfae4dc3e5f6a87b9a9
Reviewed-on: https://go-review.googlesource.com/76090
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Keith Randall 2017-11-04 14:09:50 -07:00
parent e5f6051e77
commit 989cc80167

View File

@ -48,8 +48,9 @@ func doTest(t *testing.T, filename string, kind string) {
// of the generated test. // of the generated test.
func runGenTest(t *testing.T, filename, tmpname string, ev ...string) { func runGenTest(t *testing.T, filename, tmpname string, ev ...string) {
testenv.MustHaveGoRun(t) testenv.MustHaveGoRun(t)
gotool := testenv.GoToolPath(t)
var stdout, stderr bytes.Buffer var stdout, stderr bytes.Buffer
cmd := exec.Command("go", "run", filepath.Join("testdata", filename)) cmd := exec.Command(gotool, "run", filepath.Join("testdata", filename))
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
@ -72,14 +73,14 @@ func runGenTest(t *testing.T, filename, tmpname string, ev ...string) {
// Execute compile+link+run instead of "go run" to avoid applying -gcflags=-d=ssa/check/on // Execute compile+link+run instead of "go run" to avoid applying -gcflags=-d=ssa/check/on
// to the runtime (especially over and over and over). // to the runtime (especially over and over and over).
// compile // compile
cmd = exec.Command("go", "tool", "compile", "-d=ssa/check/on", "-o", filepath.Join(tmpdir, "run.a"), rungo) cmd = exec.Command(gotool, "tool", "compile", "-d=ssa/check/on", "-o", filepath.Join(tmpdir, "run.a"), rungo)
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
cmd.Env = append(cmd.Env, ev...) cmd.Env = append(cmd.Env, ev...)
err := cmd.Run() err := cmd.Run()
if err == nil { if err == nil {
// link // link
cmd = exec.Command("go", "tool", "link", "-o", filepath.Join(tmpdir, "run.exe"), filepath.Join(tmpdir, "run.a")) cmd = exec.Command(gotool, "tool", "link", "-o", filepath.Join(tmpdir, "run.exe"), filepath.Join(tmpdir, "run.a"))
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
cmd.Env = append(cmd.Env, ev...) cmd.Env = append(cmd.Env, ev...)