"flag"
"fmt"
"go/build"
+ "internal/buildcfg"
"internal/testenv"
"internal/txtar"
"io/fs"
var execCache par.Cache
+func goExperimentIsValid(expname string) bool {
+ for _, exp := range buildcfg.Experiment.All() {
+ if expname == exp || expname == "no"+exp || "no"+expname == exp {
+ return true
+ }
+ }
+ return false
+}
+
+func goExperimentIsEnabled(expname string) bool {
+ for _, exp := range buildcfg.Experiment.Enabled() {
+ if exp == expname {
+ return true
+ }
+ }
+ return false
+}
+
// run runs the test script.
func (ts *testScript) run() {
// Truncate log at end of last phase marker,
ok = sys.BuildModeSupported(runtime.Compiler, value, runtime.GOOS, runtime.GOARCH)
break
}
+ if strings.HasPrefix(cond.tag, "GOEXPERIMENT:") {
+ rawval := strings.TrimPrefix(cond.tag, "GOEXPERIMENT:")
+ value := strings.TrimSpace(rawval)
+ if !goExperimentIsValid(value) {
+ ts.fatalf("unknown/unrecognized GOEXPERIMENT %q", value)
+ }
+ ok = goExperimentIsEnabled(value)
+ break
+ }
if !imports.KnownArch[cond.tag] && !imports.KnownOS[cond.tag] && cond.tag != "gc" && cond.tag != "gccgo" {
ts.fatalf("unknown condition %q", cond.tag)
}
- [buildmode:value] for whether -buildmode=value is supported
- [trimpath] for whether the 'go' binary was built with -trimpath
- [mismatched-goroot] for whether the test's GOROOT_FINAL does not match the real GOROOT
+ - [GOEXPERIMENT:expname] for whether the GOEXPERIMENT 'expname' is enabled
A condition can be negated: [!short] means to run the rest of the line
when testing.Short() is false. Multiple conditions may be given for a single
--- /dev/null
+# Test that [GOEXPERIMENT:x] is accepted.
+# Here fieldtrack is picked arbitrarily.
+
+[GOEXPERIMENT:nofieldtrack] env
+
+[GOEXPERIMENT:fieldtrack] env
+
+#[GOEXPERIMENT:crashme] env
+
+