execabs: disable tests on ios and js/wasm
TestCommand and TestLookPath fail on the js/wasm builder and likely
fail on ios as well.
Like the tests in internal/execabs, skip them for these platforms.
This fixes the js/wasm builder after CL 284753.
For golang/go#11811
Change-Id: I1038128bd4c7bd410ac1357dedda5e3eef5c7bbb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285712
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/execabs/execabs_test.go b/execabs/execabs_test.go
index a0b88dd..1e8cf78 100644
--- a/execabs/execabs_test.go
+++ b/execabs/execabs_test.go
@@ -15,6 +15,27 @@
"testing"
)
+// hasExec reports whether the current system can start new processes
+// using os.StartProcess or (more commonly) exec.Command.
+// Copied from internal/testenv.HasExec
+func hasExec() bool {
+ switch runtime.GOOS {
+ case "js", "ios":
+ return false
+ }
+ return true
+}
+
+// mustHaveExec checks that the current system can start new processes
+// using os.StartProcess or (more commonly) exec.Command.
+// If not, mustHaveExec calls t.Skip with an explanation.
+// Copied from internal/testenv.MustHaveExec
+func mustHaveExec(t testing.TB) {
+ if !hasExec() {
+ t.Skipf("skipping test: cannot exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH)
+ }
+}
+
func TestFixCmd(t *testing.T) {
cmd := &exec.Cmd{Path: "hello"}
fixCmd("hello", cmd)
@@ -30,6 +51,8 @@
}
func TestCommand(t *testing.T) {
+ mustHaveExec(t)
+
for _, cmd := range []func(string) *Cmd{
func(s string) *Cmd { return Command(s) },
func(s string) *Cmd { return CommandContext(context.Background(), s) },
@@ -71,6 +94,8 @@
}
func TestLookPath(t *testing.T) {
+ mustHaveExec(t)
+
tmpDir, err := ioutil.TempDir("", "execabs-test")
if err != nil {
t.Fatalf("ioutil.TempDir failed: %s", err)