aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/exec/exec_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-11-01 21:49:44 -0400
committerRuss Cox <rsc@golang.org>2011-11-01 21:49:44 -0400
commit451a1fa46d0449dc6982b38ba51cf94ebc750eca (patch)
treefb5307ac50ea9c4fe26fe7c7b306fb72aae699e7 /src/pkg/exec/exec_test.go
parentc93b6a1756be708ba2d6c8c91c4dabdbbd653cbe (diff)
downloadgo-451a1fa46d0449dc6982b38ba51cf94ebc750eca.tar.xz
exec: introduce ExitError
The existing code uses *os.Waitmsg as an os.Error, but *os.Waitmsg is really just a stringer. Introduce an explicit error type for the real error. Not to be submitted until just before error goes in; the gofix for error updates type assertions err.(*os.Waitmsg) to err.(*exec.ExitError) The seemingly redundant String method will become an Error method when error goes in, and will no longer be redundant. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5331044
Diffstat (limited to 'src/pkg/exec/exec_test.go')
-rw-r--r--src/pkg/exec/exec_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/exec/exec_test.go b/src/pkg/exec/exec_test.go
index 2b36e2535a..3183919f67 100644
--- a/src/pkg/exec/exec_test.go
+++ b/src/pkg/exec/exec_test.go
@@ -53,8 +53,8 @@ func TestCatStdin(t *testing.T) {
func TestCatGoodAndBadFile(t *testing.T) {
// Testing combined output and error values.
bs, err := helperCommand("cat", "/bogus/file.foo", "exec_test.go").CombinedOutput()
- if _, ok := err.(*os.Waitmsg); !ok {
- t.Errorf("expected Waitmsg from cat combined; got %T: %v", err, err)
+ if _, ok := err.(*ExitError); !ok {
+ t.Errorf("expected *ExitError from cat combined; got %T: %v", err, err)
}
s := string(bs)
sp := strings.SplitN(s, "\n", 2)
@@ -81,12 +81,12 @@ func TestNoExistBinary(t *testing.T) {
func TestExitStatus(t *testing.T) {
// Test that exit values are returned correctly
err := helperCommand("exit", "42").Run()
- if werr, ok := err.(*os.Waitmsg); ok {
+ if werr, ok := err.(*ExitError); ok {
if s, e := werr.String(), "exit status 42"; s != e {
t.Errorf("from exit 42 got exit %q, want %q", s, e)
}
} else {
- t.Fatalf("expected Waitmsg from exit 42; got %T: %v", err, err)
+ t.Fatalf("expected *ExitError from exit 42; got %T: %v", err, err)
}
}