From 96c23594ded3ba6b748688c1b5ead6bdbdf61229 Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Sat, 8 Feb 2020 01:06:58 +0800 Subject: [PATCH] skip race detector test on unsupported platform --- integration/flags_test.go | 3 +++ integration/integration_suite_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/integration/flags_test.go b/integration/flags_test.go index d84eb46cc..47fbc44ad 100644 --- a/integration/flags_test.go +++ b/integration/flags_test.go @@ -106,6 +106,9 @@ var _ = Describe("Flags Specs", func() { }) It("should run the race detector when told to", func() { + if !raceDetectorSupported() { + Skip("race detection is not supported") + } session := startGinkgo(pathToTest, "--noColor", "--race") Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE)) output := string(session.Out.Contents()) diff --git a/integration/integration_suite_test.go b/integration/integration_suite_test.go index 32ec741c9..27e8d52fb 100644 --- a/integration/integration_suite_test.go +++ b/integration/integration_suite_test.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -127,3 +128,15 @@ func removeSuccessfully(path string) { err := os.RemoveAll(path) Expect(err).NotTo(HaveOccurred()) } + +func raceDetectorSupported() bool { + // https://github.com/golang/go/blob/1a370950/src/cmd/internal/sys/supported.go#L12 + switch runtime.GOOS { + case "linux": + return runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "arm64" + case "darwin", "freebsd", "netbsd", "windows": + return runtime.GOARCH == "amd64" + default: + return false + } +}