1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This file contains testing utilities copied from $GOROOT/src/internal/testenv/testenv.go.
15 // HasGoBuild reports whether the current system can build programs with ``go build''
16 // and then run them with os.StartProcess or exec.Command.
17 func HasGoBuild() bool {
19 case "android", "nacl":
22 if strings.HasPrefix(runtime.GOARCH, "arm") {
29 // HasExec reports whether the current system can start new processes
30 // using os.StartProcess or (more commonly) exec.Command.
36 if strings.HasPrefix(runtime.GOARCH, "arm") {
43 // MustHaveGoBuild checks that the current system can build programs with ``go build''
44 // and then run them with os.StartProcess or exec.Command.
45 // If not, MustHaveGoBuild calls t.Skip with an explanation.
46 func MustHaveGoBuild(t *testing.T) {
48 t.Skipf("skipping test: 'go build' not available on %s/%s", runtime.GOOS, runtime.GOARCH)
52 // MustHaveExec checks that the current system can start new processes
53 // using os.StartProcess or (more commonly) exec.Command.
54 // If not, MustHaveExec calls t.Skip with an explanation.
55 func MustHaveExec(t *testing.T) {
57 t.Skipf("skipping test: cannot exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH)
61 var testenv = struct {
62 HasGoBuild func() bool
63 MustHaveGoBuild func(*testing.T)
64 MustHaveExec func(*testing.T)
66 HasGoBuild: HasGoBuild,
67 MustHaveGoBuild: MustHaveGoBuild,
68 MustHaveExec: MustHaveExec,