1
0
mirror of https://github.com/golang/go synced 2024-11-16 20:04:52 -07:00

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>
This commit is contained in:
Cherry Zhang 2021-04-11 13:26:44 -04:00
parent 51a47b7ff2
commit 9ed0e32059

View 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 {