}
}
-func makeTree(t *testing.T) FS {
+func makeTree() FS {
fsys := fstest.MapFS{}
walkTree(tree, tree.name, func(path string, n *Node) {
if n.entries == nil {
return fsys
}
-func markTree(n *Node) { walkTree(n, "", func(path string, n *Node) { n.mark++ }) }
-
-func checkMarks(t *testing.T, report bool) {
- walkTree(tree, tree.name, func(path string, n *Node) {
- if n.mark != 1 && report {
- t.Errorf("node %s mark = %d; expected 1", path, n.mark)
- }
- n.mark = 0
- })
-}
-
// Assumes that each node name is unique. Good enough for a test.
// If clear is true, any incoming error is cleared before return. The errors
// are always accumulated, though.
}
defer os.Chdir(origDir)
- fsys := makeTree(t)
+ fsys := makeTree()
errors := make([]error, 0, 10)
clear := true
markFn := func(path string, entry DirEntry, err error) error {
if len(errors) != 0 {
t.Fatalf("unexpected errors: %s", errors)
}
- checkMarks(t, true)
+ walkTree(tree, tree.name, func(path string, n *Node) {
+ if n.mark != 1 {
+ t.Errorf("node %s mark = %d; expected 1", path, n.mark)
+ }
+ n.mark = 0
+ })
}
func TestIssue51617(t *testing.T) {