]> Cypherpunks repositories - gostls13.git/commitdiff
test: consider default GOEXPERIMENT when matching build tags
authorCherry Zhang <cherryyz@google.com>
Sun, 11 Apr 2021 17:26:44 +0000 (13:26 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 12 Apr 2021 16:25:59 +0000 (16:25 +0000)
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>
test/run.go

index 48115ed18d66d6d25ee5ab2e1780c19ead15d7aa..feab88338c30bf94ddebd9fcc9e5c1619111ed37 100644 (file)
@@ -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 {