From a674ab1961ca75d902ebbdf0a3d363501fd017ae Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 26 Apr 2023 12:16:26 -0400 Subject: cmd/dist: refine test conditions and enable more cgo tests on Android, iOS This CL moves many cgo test conditions out of dist and into the tests themselves, now that they can use the testenv.Must* helpers. This refines a lot of the conditions, which happens to have the effect of enabling many tests on Android and iOS that are disabled by too-coarse GOOS checks in dist today. Fixes #15919. Change-Id: I2947526b08928d2f7f89f107b5b2403b32092ed8 Reviewed-on: https://go-review.googlesource.com/c/go/+/495918 Reviewed-by: Dmitri Shuralyov Run-TryBot: Austin Clements Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- src/internal/testenv/testenv.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/internal/testenv') diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 70606242d6..31b58ddba7 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -371,6 +371,15 @@ func MustInternalLink(t testing.TB, withCgo bool) { } } +// MustHaveBuildMode reports whether the current system can build programs in +// the given build mode. +// If not, MustHaveBuildMode calls t.Skip with an explanation. +func MustHaveBuildMode(t testing.TB, buildmode string) { + if !platform.BuildModeSupported(runtime.Compiler, buildmode, runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping test: build mode %s on %s/%s is not supported by the %s compiler", buildmode, runtime.GOOS, runtime.GOARCH, runtime.Compiler) + } +} + // HasSymlink reports whether the current system can use os.Symlink. func HasSymlink() bool { ok, _ := hasSymlink() -- cgit v1.3