From 9ed0e320599bcd559565207bb6a9b0c49a5b36ee Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sun, 11 Apr 2021 13:26:44 -0400 Subject: [PATCH] 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 Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- test/run.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/run.go b/test/run.go index 48115ed18d..feab88338c 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 {