-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
os/exec: make Cmd.Output include stderr in ExitError
Change-Id: I3c6649d2f2521ab0843b13308569867d2e5f02da Reviewed-on: https://go-review.googlesource.com/11415 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Andrew Gerrand <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
- Loading branch information
Showing
3 changed files
with
186 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2015 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package exec | ||
|
||
import ( | ||
"io" | ||
"testing" | ||
) | ||
|
||
func TestPrefixSuffixSaver(t *testing.T) { | ||
tests := []struct { | ||
N int | ||
writes []string | ||
want string | ||
}{ | ||
{ | ||
N: 2, | ||
writes: nil, | ||
want: "", | ||
}, | ||
{ | ||
N: 2, | ||
writes: []string{"a"}, | ||
want: "a", | ||
}, | ||
{ | ||
N: 2, | ||
writes: []string{"abc", "d"}, | ||
want: "abcd", | ||
}, | ||
{ | ||
N: 2, | ||
writes: []string{"abc", "d", "e"}, | ||
want: "ab\n... omitting 1 bytes ...\nde", | ||
}, | ||
{ | ||
N: 2, | ||
writes: []string{"ab______________________yz"}, | ||
want: "ab\n... omitting 22 bytes ...\nyz", | ||
}, | ||
{ | ||
N: 2, | ||
writes: []string{"ab_______________________y", "z"}, | ||
want: "ab\n... omitting 23 bytes ...\nyz", | ||
}, | ||
} | ||
for i, tt := range tests { | ||
w := &prefixSuffixSaver{N: tt.N} | ||
for _, s := range tt.writes { | ||
n, err := io.WriteString(w, s) | ||
if err != nil || n != len(s) { | ||
t.Errorf("%d. WriteString(%q) = %v, %v; want %v, %v", i, s, n, err, len(s), nil) | ||
} | ||
} | ||
if got := string(w.Bytes()); got != tt.want { | ||
t.Errorf("%d. Bytes = %q; want %q", i, got, tt.want) | ||
} | ||
} | ||
} |