From: khr@golang.org Date: Mon, 22 Jul 2024 20:27:09 +0000 (-0700) Subject: cmd/internal/testdir: fix failure when GOAMD64=v3 is specified in goenv file X-Git-Tag: go1.24rc1~1274 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d465aee0b80b8eb0b63929deb8de0b21187c59a7;p=gostls13.git cmd/internal/testdir: fix failure when GOAMD64=v3 is specified in goenv file Fixes #68548 Add GOENV=off, GOFLAGS= to the build of the stdlib, so that it matches what runcmd does. This ensures that the runtime and the test are built with the same flags. As opposed to before this CL, where flags were used in the stdlib build but not the runcmd build. (Part of the problem here is that cmd/internal/testdir/testdir_test.go plays fast and loose with the build cache to make the tests run faster. Maybe some of that fast-and-loose mechanism can be removed now that we have a better build cache? I'm not sure.) Change-Id: I449d4ff517c69311d0aa4411e7fb96c0cca49269 Reviewed-on: https://go-review.googlesource.com/c/go/+/600276 Reviewed-by: Dmitri Shuralyov Reviewed-by: Michael Matloob Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/internal/testdir/testdir_test.go b/src/cmd/internal/testdir/testdir_test.go index e64451b743..c494f2c4c0 100644 --- a/src/cmd/internal/testdir/testdir_test.go +++ b/src/cmd/internal/testdir/testdir_test.go @@ -219,7 +219,9 @@ var stdlibImportcfgString string func stdlibImportcfg() string { stdlibImportcfgStringOnce.Do(func() { - output, err := exec.Command(goTool, "list", "-export", "-f", "{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}", "std").Output() + cmd := exec.Command(goTool, "list", "-export", "-f", "{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}", "std") + cmd.Env = append(os.Environ(), "GOENV=off", "GOFLAGS=") + output, err := cmd.Output() if err != nil { log.Fatal(err) }