aboutsummaryrefslogtreecommitdiff
path: root/src/internal/testenv
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2024-09-09 11:04:13 -0700
committerGopher Robot <gobot@golang.org>2024-09-13 16:56:48 +0000
commit4c0f0985337386e0c0a3aad09251d5ee7f2b145e (patch)
tree8964cf2329c36d17fc043212c05e3443e1b8eb53 /src/internal/testenv
parentf3c89e21a566a6c82cff3e4d4b30e21de22a84fa (diff)
downloadgo-4c0f0985337386e0c0a3aad09251d5ee7f2b145e.tar.xz
internal/testenv: add MustHaveSource, rm HasSrc
All the users of HasSrc call t.Skip anyway, so let's move it to testenv. Fix go/build to use MustHaveSource rather than MustHaveGoBuild where appropriate. Change-Id: I052bf96fd5a5780c1930da5b3a52b7a8dbebea46 Reviewed-on: https://go-review.googlesource.com/c/go/+/612057 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tim King <taking@google.com> Auto-Submit: Tim King <taking@google.com>
Diffstat (limited to 'src/internal/testenv')
-rw-r--r--src/internal/testenv/testenv.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index e07e71a9b2..9aecfaa695 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -268,13 +268,14 @@ var goTool = sync.OnceValues(func() (string, error) {
return exec.LookPath("go")
})
-// HasSrc reports whether the entire source tree is available under GOROOT.
-func HasSrc() bool {
+// MustHaveSource checks that the entire source tree is available under GOROOT.
+// If not, it calls t.Skip with an explanation.
+func MustHaveSource(t testing.TB) {
switch runtime.GOOS {
case "ios":
- return false
+ t.Helper()
+ t.Skip("skipping test: no source tree on " + runtime.GOOS)
}
- return true
}
// HasExternalNetwork reports whether the current system can use