aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath/path_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-07-06 17:11:29 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2016-08-25 17:18:43 +0000
commit157fc454eccb850a0a74029a49f8d947ff1a3762 (patch)
tree5a082689ace833b432993750cb428ca3812b161e /src/path/filepath/path_test.go
parent307de6540a5e6e5c2353c410240bb0f98bab1624 (diff)
downloadgo-157fc454eccb850a0a74029a49f8d947ff1a3762.tar.xz
path/filepath: don't return SkipDir at top
If the walker function called on a top-level file returns SkipDir, then (before this change) Walk would return SkipDir, which the documentation implies will not happen. Fixes #16280. Change-Id: I37d63bdcef7af4b56e342b624cf0d4b42e65c297 Reviewed-on: https://go-review.googlesource.com/24780 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/path/filepath/path_test.go')
-rw-r--r--src/path/filepath/path_test.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index 1be5b469f2..0c495a5f1c 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -528,7 +528,7 @@ func TestWalkSkipDirOnFile(t *testing.T) {
touch(t, filepath.Join(td, "dir/foo2"))
sawFoo2 := false
- filepath.Walk(td, func(path string, info os.FileInfo, err error) error {
+ walker := func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, "foo2") {
sawFoo2 = true
}
@@ -536,8 +536,20 @@ func TestWalkSkipDirOnFile(t *testing.T) {
return filepath.SkipDir
}
return nil
- })
+ }
+ err = filepath.Walk(td, walker)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if sawFoo2 {
+ t.Errorf("SkipDir on file foo1 did not block processing of foo2")
+ }
+
+ err = filepath.Walk(filepath.Join(td, "dir"), walker)
+ if err != nil {
+ t.Fatal(err)
+ }
if sawFoo2 {
t.Errorf("SkipDir on file foo1 did not block processing of foo2")
}
@@ -1203,7 +1215,7 @@ func TestBug3486(t *testing.T) { // https://golang.org/issue/3486
ken := filepath.Join(root, "ken")
seenBugs := false
seenKen := false
- filepath.Walk(root, func(pth string, info os.FileInfo, err error) error {
+ err = filepath.Walk(root, func(pth string, info os.FileInfo, err error) error {
if err != nil {
t.Fatal(err)
}
@@ -1220,6 +1232,9 @@ func TestBug3486(t *testing.T) { // https://golang.org/issue/3486
}
return nil
})
+ if err != nil {
+ t.Fatal(err)
+ }
if !seenKen {
t.Fatalf("%q not seen", ken)
}