aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-11 13:26:44 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-12 16:25:59 +0000
commit9ed0e320599bcd559565207bb6a9b0c49a5b36ee (patch)
tree001754dcbb3a9bfb0a741aed98a8be297956b0b1 /test
parent51a47b7ff2934b6c28ece51f6a37dc30bd37a02d (diff)
downloadgo-9ed0e320599bcd559565207bb6a9b0c49a5b36ee.tar.gz
go-9ed0e320599bcd559565207bb6a9b0c49a5b36ee.zip
test: consider default GOEXPERIMENT when matching build tags
If GOEXPERIMENT environment variable is unset, use the default value that is baked into the toolchain (instead of no experiments). Change-Id: I41f863e6f7439f2d53e3ebd25a7d9cf4a176e32e Reviewed-on: https://go-review.googlesource.com/c/go/+/309333 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/run.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/run.go b/test/run.go
index 48115ed18d6..feab88338c3 100644
--- a/test/run.go
+++ b/test/run.go
@@ -446,6 +446,18 @@ func (ctxt *context) match(name string) bool {
}
exp := os.Getenv("GOEXPERIMENT")
+ if exp == "" {
+ // If GOEXPERIMENT environment variable is unset, get the default value
+ // that is baked into the toolchain.
+ cmd := exec.Command(goTool(), "tool", "compile", "-V")
+ out, err := cmd.CombinedOutput()
+ if err == nil {
+ i := bytes.Index(out, []byte("X:"))
+ if i != -1 {
+ exp = string(out[i+2:])
+ }
+ }
+ }
if exp != "" {
experiments := strings.Split(exp, ",")
for _, e := range experiments {