1
0
mirror of https://github.com/golang/go synced 2024-11-19 06:34:42 -07:00

runtime/pprof: use testenv.GoToolPath in TestMapping

The TestMapping test invokes the go tool in an exec.Command by
directly hard-coding a "go" string for the command. This can cause
test failures on systems where the "go" command points to an old
toolchain where the test is not supposed to work.

Use testenv.GoToolPath instead.

Also call 'go run' directly on the mappingtest/main.go file instead of
go-running the directory.

Change-Id: Ib91877c021209cbf4da50a561737d7a9d42c6adc
Reviewed-on: https://go-review.googlesource.com/118662
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Alberto Donizetti 2018-06-13 20:48:26 +02:00 committed by Brad Fitzpatrick
parent d8e86caa3f
commit 70c3bf27de

View File

@ -240,13 +240,13 @@ func TestMapping(t *testing.T) {
testenv.MustHaveGoRun(t) testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t) testenv.MustHaveCGO(t)
prog := "./testdata/mappingtest" prog := "./testdata/mappingtest/main.go"
// GoOnly includes only Go symbols that runtime will symbolize. // GoOnly includes only Go symbols that runtime will symbolize.
// Go+C includes C symbols that runtime will not symbolize. // Go+C includes C symbols that runtime will not symbolize.
for _, traceback := range []string{"GoOnly", "Go+C"} { for _, traceback := range []string{"GoOnly", "Go+C"} {
t.Run("traceback"+traceback, func(t *testing.T) { t.Run("traceback"+traceback, func(t *testing.T) {
cmd := exec.Command("go", "run", prog) cmd := exec.Command(testenv.GoToolPath(t), "run", prog)
if traceback != "GoOnly" { if traceback != "GoOnly" {
cmd.Env = append(os.Environ(), "SETCGOTRACEBACK=1") cmd.Env = append(os.Environ(), "SETCGOTRACEBACK=1")
} }