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/cmd/cgo/internal/testplugin/plugin_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/cmd/cgo/internal/testplugin/plugin_test.go') diff --git a/src/cmd/cgo/internal/testplugin/plugin_test.go b/src/cmd/cgo/internal/testplugin/plugin_test.go index 84ea839a2f..e211a96304 100644 --- a/src/cmd/cgo/internal/testplugin/plugin_test.go +++ b/src/cmd/cgo/internal/testplugin/plugin_test.go @@ -9,10 +9,13 @@ import ( "context" "flag" "fmt" + "internal/platform" + "internal/testenv" "log" "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" "time" @@ -44,6 +47,17 @@ func prettyPrintf(format string, args ...interface{}) { } func testMain(m *testing.M) int { + // TODO: Move all of this initialization stuff into a sync.Once that each + // test can use, where we can properly t.Skip. + if !platform.BuildModeSupported(runtime.Compiler, "plugin", runtime.GOOS, runtime.GOARCH) { + fmt.Printf("SKIP - plugin build mode not supported\n") + os.Exit(0) + } + if !testenv.HasCGO() { + fmt.Printf("SKIP - cgo not supported\n") + os.Exit(0) + } + cwd, err := os.Getwd() if err != nil { log.Fatal(err) -- cgit v1.3-5-g9baa