diff options
Diffstat (limited to 'src/os/exec/exec_test.go')
| -rw-r--r-- | src/os/exec/exec_test.go | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 33f7022a6d..dc8aebd9aa 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -290,6 +290,8 @@ func cmdYes(args ...string) { } func TestEcho(t *testing.T) { + t.Parallel() + bs, err := helperCommand(t, "echo", "foo bar", "baz").Output() if err != nil { t.Errorf("echo: %v", err) @@ -300,6 +302,8 @@ func TestEcho(t *testing.T) { } func TestCommandRelativeName(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "echo", "foo") // Run our own binary as a relative path @@ -328,6 +332,8 @@ func TestCommandRelativeName(t *testing.T) { } func TestCatStdin(t *testing.T) { + t.Parallel() + // Cat, testing stdin and stdout. input := "Input string\nLine 2" p := helperCommand(t, "cat") @@ -343,6 +349,8 @@ func TestCatStdin(t *testing.T) { } func TestEchoFileRace(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "echo") stdin, err := cmd.StdinPipe() if err != nil { @@ -363,6 +371,8 @@ func TestEchoFileRace(t *testing.T) { } func TestCatGoodAndBadFile(t *testing.T) { + t.Parallel() + // Testing combined output and error values. bs, err := helperCommand(t, "cat", "/bogus/file.foo", "exec_test.go").CombinedOutput() if _, ok := err.(*exec.ExitError); !ok { @@ -381,6 +391,8 @@ func TestCatGoodAndBadFile(t *testing.T) { } func TestNoExistExecutable(t *testing.T) { + t.Parallel() + // Can't run a non-existent executable err := exec.Command("/no-exist-executable").Run() if err == nil { @@ -389,6 +401,8 @@ func TestNoExistExecutable(t *testing.T) { } func TestExitStatus(t *testing.T) { + t.Parallel() + // Test that exit values are returned correctly cmd := helperCommand(t, "exit", "42") err := cmd.Run() @@ -407,6 +421,8 @@ func TestExitStatus(t *testing.T) { } func TestExitCode(t *testing.T) { + t.Parallel() + // Test that exit code are returned correctly cmd := helperCommand(t, "exit", "42") cmd.Run() @@ -459,6 +475,8 @@ func TestExitCode(t *testing.T) { } func TestPipes(t *testing.T) { + t.Parallel() + check := func(what string, err error) { if err != nil { t.Fatalf("%s: %v", what, err) @@ -513,6 +531,8 @@ const stdinCloseTestString = "Some test string." // Issue 6270. func TestStdinClose(t *testing.T) { + t.Parallel() + check := func(what string, err error) { if err != nil { t.Fatalf("%s: %v", what, err) @@ -544,6 +564,8 @@ func TestStdinClose(t *testing.T) { // This test is run by cmd/dist under the race detector to verify that // the race detector no longer reports any problems. func TestStdinCloseRace(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "stdinClose") stdin, err := cmd.StdinPipe() if err != nil { @@ -582,6 +604,7 @@ func TestPipeLookPathLeak(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("we don't currently suppore counting open handles on windows") } + // Not parallel: checks for leaked file descriptors openFDs := func() []uintptr { var fds []uintptr @@ -610,6 +633,10 @@ func TestPipeLookPathLeak(t *testing.T) { } func TestExtraFiles(t *testing.T) { + if testing.Short() { + t.Skipf("skipping test in short mode that would build a helper binary") + } + if haveUnexpectedFDs { // The point of this test is to make sure that any // descriptors we open are marked close-on-exec. @@ -742,6 +769,8 @@ func TestExtraFilesRace(t *testing.T) { maySkipHelperCommand("describefiles") t.Skip("no operating system support; skipping") } + t.Parallel() + listen := func() net.Listener { ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { @@ -793,7 +822,6 @@ func TestExtraFilesRace(t *testing.T) { for _, f := range cb.ExtraFiles { f.Close() } - } } @@ -809,8 +837,12 @@ func (delayedInfiniteReader) Read(b []byte) (int, error) { // Issue 9173: ignore stdin pipe writes if the program completes successfully. func TestIgnorePipeErrorOnSuccess(t *testing.T) { + t.Parallel() + testWith := func(r io.Reader) func(*testing.T) { return func(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "echo", "foo") var out strings.Builder cmd.Stdin = r @@ -834,6 +866,8 @@ func (w *badWriter) Write(data []byte) (int, error) { } func TestClosePipeOnCopyError(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "yes") cmd.Stdout = new(badWriter) err := cmd.Run() @@ -843,6 +877,8 @@ func TestClosePipeOnCopyError(t *testing.T) { } func TestOutputStderrCapture(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "stderrfail") _, err := cmd.Output() ee, ok := err.(*exec.ExitError) @@ -857,6 +893,8 @@ func TestOutputStderrCapture(t *testing.T) { } func TestContext(t *testing.T) { + t.Parallel() + ctx, cancel := context.WithCancel(context.Background()) c := helperCommandContext(t, ctx, "pipetest") stdin, err := c.StdinPipe() @@ -950,6 +988,8 @@ func TestContextCancel(t *testing.T) { // test that environment variables are de-duped. func TestDedupEnvEcho(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "echoenv", "FOO") cmd.Env = append(cmd.Environ(), "FOO=bad", "FOO=good") out, err := cmd.CombinedOutput() @@ -962,6 +1002,8 @@ func TestDedupEnvEcho(t *testing.T) { } func TestString(t *testing.T) { + t.Parallel() + echoPath, err := exec.LookPath("echo") if err != nil { t.Skip(err) @@ -984,10 +1026,13 @@ func TestString(t *testing.T) { } func TestStringPathNotResolved(t *testing.T) { + t.Parallel() + _, err := exec.LookPath("makemeasandwich") if err == nil { t.Skip("wow, thanks") } + cmd := exec.Command("makemeasandwich", "-lettuce") want := "makemeasandwich -lettuce" if got := cmd.String(); got != want { @@ -1007,6 +1052,8 @@ func TestNoPath(t *testing.T) { // Start twice, which returns an error on the second call, would spuriously // close the pipes established in the first call. func TestDoubleStartLeavesPipesOpen(t *testing.T) { + t.Parallel() + cmd := helperCommand(t, "pipetest") in, err := cmd.StdinPipe() if err != nil { |
