@@ -34,21 +34,21 @@ func scriptConditions() map[string]script.Cond {
34
34
return script .OnceCondition (summary , func () (bool , error ) { return f (), nil })
35
35
}
36
36
37
- add ("asan" , sysCondition ("-asan" , platform .ASanSupported ))
37
+ add ("asan" , sysCondition ("-asan" , platform .ASanSupported , true ))
38
38
add ("buildmode" , script .PrefixCondition ("go supports -buildmode=<suffix>" , hasBuildmode ))
39
39
add ("case-sensitive" , script .OnceCondition ("$WORK filesystem is case-sensitive" , isCaseSensitive ))
40
40
add ("cgo" , script .BoolCondition ("host CGO_ENABLED" , canCgo ))
41
41
add ("cross" , script .BoolCondition ("cmd/go GOOS/GOARCH != GOHOSTOS/GOHOSTARCH" , goHostOS != runtime .GOOS || goHostArch != runtime .GOARCH ))
42
- add ("fuzz" , sysCondition ("-fuzz" , platform .FuzzSupported ))
43
- add ("fuzz-instrumented" , sysCondition ("-fuzz with instrumentation" , platform .FuzzInstrumented ))
42
+ add ("fuzz" , sysCondition ("-fuzz" , platform .FuzzSupported , false ))
43
+ add ("fuzz-instrumented" , sysCondition ("-fuzz with instrumentation" , platform .FuzzInstrumented , false ))
44
44
add ("git" , lazyBool ("the 'git' executable exists and provides the standard CLI" , hasWorkingGit ))
45
45
add ("GODEBUG" , script .PrefixCondition ("GODEBUG contains <suffix>" , hasGodebug ))
46
46
add ("GOEXPERIMENT" , script .PrefixCondition ("GOEXPERIMENT <suffix> is enabled" , hasGoexperiment ))
47
47
add ("link" , lazyBool ("testenv.HasLink()" , testenv .HasLink ))
48
48
add ("mismatched-goroot" , script .Condition ("test's GOROOT_FINAL does not match the real GOROOT" , isMismatchedGoroot ))
49
- add ("msan" , sysCondition ("-msan" , platform .MSanSupported ))
49
+ add ("msan" , sysCondition ("-msan" , platform .MSanSupported , true ))
50
50
add ("net" , lazyBool ("testenv.HasExternalNetwork()" , testenv .HasExternalNetwork ))
51
- add ("race" , sysCondition ("-race" , platform .RaceDetectorSupported ))
51
+ add ("race" , sysCondition ("-race" , platform .RaceDetectorSupported , true ))
52
52
add ("symlink" , lazyBool ("testenv.HasSymlink()" , testenv .HasSymlink ))
53
53
add ("trimpath" , script .OnceCondition ("test binary was built with -trimpath" , isTrimpath ))
54
54
@@ -63,13 +63,14 @@ func isMismatchedGoroot(s *script.State) (bool, error) {
63
63
return gorootFinal != testGOROOT , nil
64
64
}
65
65
66
- func sysCondition (flag string , f func (goos , goarch string ) bool ) script.Cond {
66
+ func sysCondition (flag string , f func (goos , goarch string ) bool , needsCgo bool ) script.Cond {
67
67
return script .Condition (
68
68
"GOOS/GOARCH supports " + flag ,
69
69
func (s * script.State ) (bool , error ) {
70
70
GOOS , _ := s .LookupEnv ("GOOS" )
71
71
GOARCH , _ := s .LookupEnv ("GOARCH" )
72
- return f (GOOS , GOARCH ), nil
72
+ cross := goHostOS != GOOS || goHostArch != GOARCH
73
+ return (! needsCgo || (canCgo && ! cross )) && f (GOOS , GOARCH ), nil
73
74
})
74
75
}
75
76
0 commit comments