From 4b3658880752ca30a2ad5f2dc33a9bee9ff91de4 Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Tue, 28 May 2019 23:07:56 +0700 Subject: cmd/go: add go command known variables to test cache hash The go test result must not be cached when each of known variables to go command change. To do this, add all known variables to test metadata. Fixes #32285 Change-Id: I90be6a72f46c42d965aec4fed534c0623244cd3d Reviewed-on: https://go-review.googlesource.com/c/go/+/179040 Run-TryBot: Cuong Manh Le TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills Reviewed-by: Jay Conrod --- src/internal/testenv/testenv.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/internal/testenv') diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index c27fcfa208..f7a9730ca6 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -13,6 +13,7 @@ package testenv import ( "errors" "flag" + "internal/cfg" "os" "os/exec" "path/filepath" @@ -88,6 +89,12 @@ func GoToolPath(t testing.TB) string { if err != nil { t.Fatal(err) } + // Add all environment variables that affect the Go command to test metadata. + // Cached test results will be invalidate when these variables change. + // See golang.org/issue/32285. + for _, envVar := range strings.Fields(cfg.KnownEnv) { + os.Getenv(envVar) + } return path } -- cgit v1.3