@@ -100,8 +100,9 @@ var update = flag.Bool("update", false, "if set, update test data during marker
100
100
// There are three types of file within the test archive that are given special
101
101
// treatment by the test runner:
102
102
// - "flags": this file is treated as a whitespace-separated list of flags
103
- // that configure the MarkerTest instance. For example, -min_go=go1.18 sets
104
- // the minimum required Go version for the test.
103
+ // that configure the MarkerTest instance. Supported flags:
104
+ // -min_go=go1.18 sets the minimum Go version for the test;
105
+ // -cgo requires that CGO_ENABLED is set and the cgo tool is available
105
106
// TODO(rfindley): support flag values containing whitespace.
106
107
// - "settings.json": this file is parsed as JSON, and used as the
107
108
// session configuration (see gopls/doc/settings.md)
@@ -340,6 +341,9 @@ func RunMarkerTests(t *testing.T, dir string) {
340
341
}
341
342
testenv .NeedsGo1Point (t , go1point )
342
343
}
344
+ if test .cgo {
345
+ testenv .NeedsTool (t , "cgo" )
346
+ }
343
347
config := fake.EditorConfig {
344
348
Settings : test .settings ,
345
349
Env : test .env ,
@@ -553,13 +557,15 @@ type markerTest struct {
553
557
flags []string
554
558
// Parsed flags values.
555
559
minGoVersion string
560
+ cgo bool
556
561
}
557
562
558
563
// flagSet returns the flagset used for parsing the special "flags" file in the
559
564
// test archive.
560
565
func (t * markerTest ) flagSet () * flag.FlagSet {
561
566
flags := flag .NewFlagSet (t .name , flag .ContinueOnError )
562
567
flags .StringVar (& t .minGoVersion , "min_go" , "" , "if set, the minimum go1.X version required for this test" )
568
+ flags .BoolVar (& t .cgo , "cgo" , false , "if set, requires cgo (both the cgo tool and CGO_ENABLED=1)" )
563
569
return flags
564
570
}
565
571
0 commit comments