aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2012-01-25 20:19:55 -0800
committerRob Pike <r@golang.org>2012-01-25 20:19:55 -0800
commitf8a28ecc9f9ab0ca6a65ca4af4f5a7f3256f6a96 (patch)
tree380c06a64f33fde2b2dd0f8c5a182b1a1304b33a
parent7b5048570a32f477cd946298a643ae89c7a01f3c (diff)
downloadgo-f8a28ecc9f9ab0ca6a65ca4af4f5a7f3256f6a96.tar.gz
go-f8a28ecc9f9ab0ca6a65ca4af4f5a7f3256f6a96.zip
path/filepath: fix test
If there's an error, sometimes you need to stop. Part of issue 2787. R=golang-dev, adg CC=golang-dev https://golang.org/cl/5570068
-rw-r--r--src/pkg/path/filepath/path_test.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pkg/path/filepath/path_test.go b/src/pkg/path/filepath/path_test.go
index 966b08e4f8..11b636cac7 100644
--- a/src/pkg/path/filepath/path_test.go
+++ b/src/pkg/path/filepath/path_test.go
@@ -296,6 +296,7 @@ func makeTree(t *testing.T) {
fd, err := os.Create(path)
if err != nil {
t.Errorf("makeTree: %v", err)
+ return
}
fd.Close()
} else {
@@ -345,10 +346,10 @@ func TestWalk(t *testing.T) {
// Expect no errors.
err := filepath.Walk(tree.name, markFn)
if err != nil {
- t.Errorf("no error expected, found: %s", err)
+ t.Fatalf("no error expected, found: %s", err)
}
if len(errors) != 0 {
- t.Errorf("unexpected errors: %s", errors)
+ t.Fatalf("unexpected errors: %s", errors)
}
checkMarks(t, true)
errors = errors[0:0]
@@ -370,7 +371,7 @@ func TestWalk(t *testing.T) {
tree.entries[3].mark--
err := filepath.Walk(tree.name, markFn)
if err != nil {
- t.Errorf("expected no error return from Walk, %s", err)
+ t.Fatalf("expected no error return from Walk, got %s", err)
}
if len(errors) != 2 {
t.Errorf("expected 2 errors, got %d: %s", len(errors), errors)
@@ -389,7 +390,7 @@ func TestWalk(t *testing.T) {
clear = false // error will stop processing
err = filepath.Walk(tree.name, markFn)
if err == nil {
- t.Errorf("expected error return from Walk")
+ t.Fatalf("expected error return from Walk")
}
if len(errors) != 1 {
t.Errorf("expected 1 error, got %d: %s", len(errors), errors)
@@ -657,11 +658,13 @@ func TestAbs(t *testing.T) {
info, err := os.Stat(path)
if err != nil {
t.Errorf("%s: %s", path, err)
+ continue
}
abspath, err := filepath.Abs(path)
if err != nil {
t.Errorf("Abs(%q) error: %v", path, err)
+ continue
}
absinfo, err := os.Stat(abspath)
if err != nil || !absinfo.(*os.FileStat).SameFile(info.(*os.FileStat)) {