diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-07-13 18:17:24 -0600 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-07-14 00:41:31 +0000 |
| commit | 73ca459a56ef003ad0892ef46454bc98afd30a05 (patch) | |
| tree | 5fec32de411d15ee26497d08ee23e87e2d00bbce /src/os/exec/exec_test.go | |
| parent | 3c5eb96001453466656873a2d5c8921d8baebfcd (diff) | |
| download | go-73ca459a56ef003ad0892ef46454bc98afd30a05.tar.xz | |
os/exec: ignore pipe write errors when command completes successfully
Fixes #9173
Change-Id: I83530533db84b07cb88dbf6ec690be48a06a9d7d
Reviewed-on: https://go-review.googlesource.com/12152
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec_test.go')
| -rw-r--r-- | src/os/exec/exec_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 96d41cbc8e..6888d29cd8 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -765,3 +765,24 @@ func TestHelperProcess(*testing.T) { os.Exit(2) } } + +// Issue 9173: ignore stdin pipe writes if the program completes successfully. +func TestIgnorePipeErrorOnSuccess(t *testing.T) { + testenv.MustHaveExec(t) + + // We really only care about testing this on Unixy things. + if runtime.GOOS == "windows" || runtime.GOOS == "plan9" { + t.Skipf("skipping test on %q", runtime.GOOS) + } + + cmd := helperCommand(t, "echo", "foo") + var out bytes.Buffer + cmd.Stdin = strings.NewReader(strings.Repeat("x", 10<<20)) + cmd.Stdout = &out + if err := cmd.Run(); err != nil { + t.Fatal(err) + } + if got, want := out.String(), "foo\n"; got != want { + t.Errorf("output = %q; want %q", got, want) + } +} |
