Skip to content

Commit a3c1704

Browse files
findleyrgopherbot
authored andcommitted
cmd/gotelemetry: fix failing TestDocHelp on mobile operating systems
This test is failing due to not being able to exec. Fix this by porting a simplified version of the standard library's testenv.MustHaveExec. Change-Id: I5e09cb2af1be77df8ec4d88be3e2a5a6115d04b6 Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/530979 Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Peter Weinberger <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent 3d293c8 commit a3c1704

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmd/gotelemetry/help_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"os/exec"
1515
"strings"
1616
"testing"
17+
18+
"golang.org/x/telemetry/internal/testenv"
1719
)
1820

1921
var updateDocs = flag.Bool("update", false, "if set, update docs")
@@ -27,6 +29,8 @@ func TestMain(m *testing.M) {
2729
}
2830

2931
func TestDocHelp(t *testing.T) {
32+
testenv.MustHaveExec(t)
33+
3034
exe, err := os.Executable()
3135
if err != nil {
3236
t.Fatal(err)

internal/testenv/testenv.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ func SkipIfUnsupportedPlatform(t testing.TB) {
6767
t.Skip("broken for GOARCH 386")
6868
}
6969
}
70+
71+
// MustHaveExec checks that the current system can start new processes
72+
// using os.StartProcess or (more commonly) exec.Command.
73+
// If not, MustHaveExec calls t.Skip with an explanation.
74+
func MustHaveExec(t testing.TB) {
75+
switch runtime.GOOS {
76+
case "wasip1", "js", "ios":
77+
t.Skipf("skipping test: may not be able to exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH)
78+
}
79+
}

0 commit comments

Comments
 (0)