summaryrefslogtreecommitdiffstats
path: root/tpl/internal/go_templates/testenv/testenv.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-12-03 13:50:17 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-02-18 14:11:48 +0100
commitcf3e077da304e6f4d7c22f8296e1382335d055c6 (patch)
treedbcec1614cc8e8de56921f4a316fd316dee07f67 /tpl/internal/go_templates/testenv/testenv.go
parent66beac99c64b5e5fe7bec0bda437ba5858d49a36 (diff)
tpl/internal: Synch Go templates fork with Go 1.16dev
Diffstat (limited to 'tpl/internal/go_templates/testenv/testenv.go')
-rw-r--r--tpl/internal/go_templates/testenv/testenv.go64
1 files changed, 50 insertions, 14 deletions
diff --git a/tpl/internal/go_templates/testenv/testenv.go b/tpl/internal/go_templates/testenv/testenv.go
index f5ea398fb..5bd91591a 100644
--- a/tpl/internal/go_templates/testenv/testenv.go
+++ b/tpl/internal/go_templates/testenv/testenv.go
@@ -45,12 +45,8 @@ func HasGoBuild() bool {
return false
}
switch runtime.GOOS {
- case "android", "js":
+ case "android", "js", "ios":
return false
- case "darwin":
- if runtime.GOARCH == "arm64" {
- return false
- }
}
return true
}
@@ -124,12 +120,8 @@ func GoTool() (string, error) {
// using os.StartProcess or (more commonly) exec.Command.
func HasExec() bool {
switch runtime.GOOS {
- case "js":
+ case "js", "ios":
return false
- case "darwin":
- if runtime.GOARCH == "arm64" {
- return false
- }
}
return true
}
@@ -137,10 +129,8 @@ func HasExec() bool {
// HasSrc reports whether the entire source tree is available under GOROOT.
func HasSrc() bool {
switch runtime.GOOS {
- case "darwin":
- if runtime.GOARCH == "arm64" {
- return false
- }
+ case "ios":
+ return false
}
return true
}
@@ -204,6 +194,32 @@ func MustHaveCGO(t testing.TB) {
}
}
+// CanInternalLink reports whether the current system can link programs with
+// internal linking.
+// (This is the opposite of cmd/internal/sys.MustLinkExternal. Keep them in sync.)
+func CanInternalLink() bool {
+ switch runtime.GOOS {
+ case "android":
+ if runtime.GOARCH != "arm64" {
+ return false
+ }
+ case "ios":
+ if runtime.GOARCH == "arm64" {
+ return false
+ }
+ }
+ return true
+}
+
+// MustInternalLink checks that the current system can link programs with internal
+// linking.
+// If not, MustInternalLink calls t.Skip with an explanation.
+func MustInternalLink(t testing.TB) {
+ if !CanInternalLink() {
+ t.Skipf("skipping test: internal linking on %s/%s is not supported", runtime.GOOS, runtime.GOARCH)
+ }
+}
+
// HasSymlink reports whether the current system can use os.Symlink.
func HasSymlink() bool {
ok, _ := hasSymlink()
@@ -272,3 +288,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)
+ }
+}