]> Cypherpunks repositories - gostls13.git/commitdiff
test: more robust detection of GOEXPERIMENT=unified
authorMatthew Dempsky <mdempsky@google.com>
Tue, 9 Aug 2022 07:30:15 +0000 (00:30 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 10 Aug 2022 18:52:00 +0000 (18:52 +0000)
`go env GOEXPERIMENT` prints what experiments are enabled relative to
the baseline configuration, so it's not a very robust way to detect
what experiments have been statically enabled at bootstrap time.

Instead, we can check build.Default.ToolTags, which has goexperiment.*
for all currently enabled experiments, independent of baseline.

Change-Id: I6132deaa73b1e79ac24176ef4de5af67a507ee26
Reviewed-on: https://go-review.googlesource.com/c/go/+/422234
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
test/run.go

index c263a41877e8ab14d4a4180898461a4c8756d030..3665a186a4a9ca1dedb465d2c812955222ed23a0 100644 (file)
@@ -75,10 +75,14 @@ var env = func() (res envVars) {
        return
 }()
 
-// TODO(mdempsky): This will give false negatives if the unified
-// experiment is enabled by default, but presumably at that point we
-// won't need to disable tests for it anymore anyway.
-var unifiedEnabled = strings.Contains(","+env.GOEXPERIMENT+",", ",unified,")
+var unifiedEnabled = func() bool {
+       for _, tag := range build.Default.ToolTags {
+               if tag == "goexperiment.unified" {
+                       return true
+               }
+       }
+       return false
+}()
 
 // defaultAllCodeGen returns the default value of the -all_codegen
 // flag. By default, we prefer to be fast (returning false), except on