mirror of
https://github.com/golang/sys.git
synced 2026-01-29 07:02:06 +03:00
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>
This commit is contained in:
committed by
Tobias Klauser
parent
a8b976e07c
commit
9b0068b266
@@ -15,6 +15,27 @@ import (
|
||||
"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 TestFixCmd(t *testing.T) {
|
||||
}
|
||||
|
||||
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 TestCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLookPath(t *testing.T) {
|
||||
mustHaveExec(t)
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "execabs-test")
|
||||
if err != nil {
|
||||
t.Fatalf("ioutil.TempDir failed: %s", err)
|
||||
|
||||
Reference in New Issue
Block a user