Skip to content

Commit 9fffcde

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
cmd/go: fix script conditions that require cgo
This fixes a regression introduced in CL 419875 that causes features that require cgo to be tested on the nocgo builders. For #27494. Change-Id: Iee61225c98c1275810256ab002a698fc4b42c053 Reviewed-on: https://go-review.googlesource.com/c/go/+/445235 Auto-Submit: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 3617514 commit 9fffcde

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/cmd/go/scriptconds_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ func scriptConditions() map[string]script.Cond {
3434
return script.OnceCondition(summary, func() (bool, error) { return f(), nil })
3535
}
3636

37-
add("asan", sysCondition("-asan", platform.ASanSupported))
37+
add("asan", sysCondition("-asan", platform.ASanSupported, true))
3838
add("buildmode", script.PrefixCondition("go supports -buildmode=<suffix>", hasBuildmode))
3939
add("case-sensitive", script.OnceCondition("$WORK filesystem is case-sensitive", isCaseSensitive))
4040
add("cgo", script.BoolCondition("host CGO_ENABLED", canCgo))
4141
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))
4444
add("git", lazyBool("the 'git' executable exists and provides the standard CLI", hasWorkingGit))
4545
add("GODEBUG", script.PrefixCondition("GODEBUG contains <suffix>", hasGodebug))
4646
add("GOEXPERIMENT", script.PrefixCondition("GOEXPERIMENT <suffix> is enabled", hasGoexperiment))
4747
add("link", lazyBool("testenv.HasLink()", testenv.HasLink))
4848
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))
5050
add("net", lazyBool("testenv.HasExternalNetwork()", testenv.HasExternalNetwork))
51-
add("race", sysCondition("-race", platform.RaceDetectorSupported))
51+
add("race", sysCondition("-race", platform.RaceDetectorSupported, true))
5252
add("symlink", lazyBool("testenv.HasSymlink()", testenv.HasSymlink))
5353
add("trimpath", script.OnceCondition("test binary was built with -trimpath", isTrimpath))
5454

@@ -63,13 +63,14 @@ func isMismatchedGoroot(s *script.State) (bool, error) {
6363
return gorootFinal != testGOROOT, nil
6464
}
6565

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 {
6767
return script.Condition(
6868
"GOOS/GOARCH supports "+flag,
6969
func(s *script.State) (bool, error) {
7070
GOOS, _ := s.LookupEnv("GOOS")
7171
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
7374
})
7475
}
7576

0 commit comments

Comments
 (0)