diff options
author | Bryan C. Mills <bcmills@google.com> | 2020-10-28 10:44:24 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2020-10-28 19:37:03 +0000 |
commit | 07d206f7698f4d45544a2f9b6051ede594ba04cc (patch) | |
tree | 4b11517b805b51dc36bb2b03117f76feda39d1e1 /src/internal | |
parent | 87d59bcdc354b035e17a1dadbfc4883bbcac5bf8 (diff) | |
download | go-07d206f7698f4d45544a2f9b6051ede594ba04cc.tar.gz go-07d206f7698f4d45544a2f9b6051ede594ba04cc.zip |
cmd/go: use internal/testenv instead of computing canRun and skipExternal ad-hoc
Fixes #42223
Change-Id: Icf9bb61d48f0a6c7fd6f74e80e333a4837aa52ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/265781
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/testenv/testenv.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index dff68869bd..c902b1404f 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -286,3 +286,23 @@ func CleanCmdEnv(cmd *exec.Cmd) *exec.Cmd { } return cmd } + +// CPUIsSlow reports whether the CPU running the test is suspected to be slow. +func CPUIsSlow() bool { + switch runtime.GOARCH { + case "arm", "mips", "mipsle", "mips64", "mips64le": + return true + } + return false +} + +// SkipIfShortAndSlow skips t if -short is set and the CPU running the test is +// suspected to be slow. +// +// (This is useful for CPU-intensive tests that otherwise complete quickly.) +func SkipIfShortAndSlow(t testing.TB) { + if testing.Short() && CPUIsSlow() { + t.Helper() + t.Skipf("skipping test in -short mode on %s", runtime.GOARCH) + } +} |