]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/testdir: fix failure when GOAMD64=v3 is specified in goenv file
authorkhr@golang.org <khr@golang.org>
Mon, 22 Jul 2024 20:27:09 +0000 (13:27 -0700)
committerKeith Randall <khr@golang.org>
Mon, 5 Aug 2024 13:12:12 +0000 (13:12 +0000)
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 <dmitshur@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/internal/testdir/testdir_test.go

index e64451b743a87b7224c003d789b806d293cfc73e..c494f2c4c0125e93d2ccf2385b9de6c1a4b83366 100644 (file)
@@ -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)
                }