mirror of https://github.com/golang/go.git
internal/testenv: add a NeedsGoBuild function
This function will skip tests in test environments where the go command can't be used to build and run binaries. This will be used by the test in golang.org/cl/236758 Change-Id: Ie61e8890084179b0e999dd377148693395043191 Reviewed-on: https://go-review.googlesource.com/c/tools/+/236920 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
7567580308
commit
03e6e36be9
|
|
@ -220,6 +220,27 @@ func NeedsGoPackagesEnv(t Testing, env []string) {
|
|||
NeedsGoPackages(t)
|
||||
}
|
||||
|
||||
// NeedsGoBuild skips t if the current system can't build programs with ``go build''
|
||||
// and then run them with os.StartProcess or exec.Command.
|
||||
// android, and darwin/arm systems don't have the userspace go build needs to run,
|
||||
// and js/wasm doesn't support running subprocesses.
|
||||
func NeedsGoBuild(t Testing) {
|
||||
if t, ok := t.(helperer); ok {
|
||||
t.Helper()
|
||||
}
|
||||
|
||||
NeedsTool(t, "go")
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "android", "js":
|
||||
t.Skipf("skipping test: %v can't build and run Go binaries", runtime.GOOS)
|
||||
case "darwin":
|
||||
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
||||
t.Skipf("skipping test: darwin/arm can't build and run Go binaries")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ExitIfSmallMachine emits a helpful diagnostic and calls os.Exit(0) if the
|
||||
// current machine is a builder known to have scarce resources.
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue