diff options
Diffstat (limited to 'src/path/filepath/path_test.go')
| -rw-r--r-- | src/path/filepath/path_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index cfd0c8244d..1456ea737a 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1526,3 +1526,38 @@ func TestEvalSymlinksAboveRootChdir(t *testing.T) { t.Logf("EvalSymlinks(%q) = %q", check, resolved) } } + +func TestIssue51617(t *testing.T) { + dir := t.TempDir() + for _, sub := range []string{"a", filepath.Join("a", "bad"), filepath.Join("a", "next")} { + if err := os.Mkdir(filepath.Join(dir, sub), 0755); err != nil { + t.Fatal(err) + } + } + bad := filepath.Join(dir, "a", "bad") + if err := os.Chmod(bad, 0); err != nil { + t.Fatal(err) + } + defer os.Chmod(bad, 0700) // avoid errors on cleanup + var saw []string + err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return filepath.SkipDir + } + if d.IsDir() { + rel, err := filepath.Rel(dir, path) + if err != nil { + t.Fatal(err) + } + saw = append(saw, rel) + } + return nil + }) + if err != nil { + t.Fatal(err) + } + want := []string{".", "a", filepath.Join("a", "bad"), filepath.Join("a", "next")} + if !reflect.DeepEqual(saw, want) { + t.Errorf("got directories %v, want %v", saw, want) + } +} |
