aboutsummaryrefslogtreecommitdiff
path: root/src/internal/testenv
diff options
context:
space:
mode:
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>2019-05-28 23:07:56 +0700
committerJay Conrod <jayconrod@google.com>2019-07-15 16:28:58 +0000
commit4b3658880752ca30a2ad5f2dc33a9bee9ff91de4 (patch)
tree8f69d0d4d16d01a53736e37da335a0f29b970439 /src/internal/testenv
parent89d300b821551c9955414caf3066ae602813f6ea (diff)
downloadgo-4b3658880752ca30a2ad5f2dc33a9bee9ff91de4.tar.xz
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 <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/internal/testenv')
-rw-r--r--src/internal/testenv/testenv.go7
1 files changed, 7 insertions, 0 deletions
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
}