From 7bc3e5880675ce4aae245f46d193924cff5efdfb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Jun 2015 11:01:53 -0400 Subject: all: extract "can I exec?" check from tests into internal/testenv Change-Id: I7b54be9d8b50b39e01c6be21f310ae9a10404e9d Reviewed-on: https://go-review.googlesource.com/10753 Reviewed-by: Brad Fitzpatrick Reviewed-by: David Crawshaw Reviewed-by: Ian Lance Taylor --- src/os/exec/exec_test.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/os/exec/exec_test.go') diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index db84eabf26..3773963cb0 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -11,6 +11,7 @@ import ( "bufio" "bytes" "fmt" + "internal/testenv" "io" "io/ioutil" "log" @@ -27,13 +28,9 @@ import ( "time" ) -// iOS cannot fork -var iOS = runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") - func helperCommand(t *testing.T, s ...string) *exec.Cmd { - if runtime.GOOS == "nacl" || iOS { - t.Skipf("skipping on %s/%s, cannot fork", runtime.GOOS, runtime.GOARCH) - } + testenv.MustHaveExec(t) + cs := []string{"-test.run=TestHelperProcess", "--"} cs = append(cs, s...) cmd := exec.Command(os.Args[0], cs...) @@ -52,9 +49,7 @@ func TestEcho(t *testing.T) { } func TestCommandRelativeName(t *testing.T) { - if iOS { - t.Skip("skipping on darwin/%s, cannot fork", runtime.GOARCH) - } + testenv.MustHaveExec(t) // Run our own binary as a relative path // (e.g. "_test/exec.test") our parent directory. @@ -427,13 +422,11 @@ func TestExtraFilesFDShuffle(t *testing.T) { } func TestExtraFiles(t *testing.T) { - switch runtime.GOOS { - case "nacl", "windows": + testenv.MustHaveExec(t) + + if runtime.GOOS == "windows" { t.Skipf("skipping test on %q", runtime.GOOS) } - if iOS { - t.Skipf("skipping test on %s/%s, cannot fork", runtime.GOOS, runtime.GOARCH) - } // Ensure that file descriptors have not already been leaked into // our environment. -- cgit v1.3