authorgravatar for hkupty@gmail.comHenry Kupty <hkupty@gmail.com> 2025-09-25 22:39:11+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-10-03 16:29:08-07:00
loga26a654c55e0f3015e03b745b4c22b2bc90d3dc9
treed90d830a2f31cc829469667e03e976ce19004f53
parentec4514def41db988f89c2da180f7a8f87168f5d1

test: Include expected depth test


1 files changed, 12 insertions(+), 7 deletions(-)

lib/std/fs/test.zig+12-7
...@@ -1823,13 +1823,13 @@ test "selective walker, skip entries that start with ." {...@@ -1823,13 +1823,13 @@ test "selective walker, skip entries that start with ." {
18231823
1824 // iteration order of walker is undefined, so need lookup maps to check against1824 // iteration order of walker is undefined, so need lookup maps to check against
18251825
1826 const expected_paths = std.StaticStringMap(void).initComptime(.{1826 const expected_paths = std.StaticStringMap(usize).initComptime(.{
1827 .{"dir1"},1827 .{ "dir1", 1 },
1828 .{"dir1" ++ fs.path.sep_str ++ "foo"},1828 .{ "dir1" ++ fs.path.sep_str ++ "foo", 2 },
1829 .{"a"},1829 .{ "a", 1 },
1830 .{"a" ++ fs.path.sep_str ++ "b"},1830 .{ "a" ++ fs.path.sep_str ++ "b", 2 },
1831 .{"a" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"},1831 .{ "a" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c", 3 },
1832 .{"a" ++ fs.path.sep_str ++ "baz"},1832 .{ "a" ++ fs.path.sep_str ++ "baz", 2 },
1833 });1833 });
18341834
1835 const expected_basenames = std.StaticStringMap(void).initComptime(.{1835 const expected_basenames = std.StaticStringMap(void).initComptime(.{
...@@ -1863,6 +1863,11 @@ test "selective walker, skip entries that start with ." {...@@ -1863,6 +1863,11 @@ test "selective walker, skip entries that start with ." {
1863 std.debug.print("found unexpected path: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)});1863 std.debug.print("found unexpected path: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)});
1864 return err;1864 return err;
1865 };1865 };
1866
1867 testing.expectEqual(expected_paths.get(entry.path).?, walker.depth()) catch |err| {
1868 std.debug.print("path reported unexpected depth: {f}, {d}", .{ std.ascii.hexEscape(entry.path, .lower), walker.depth() });
1869 return err;
1870 };
1866 // make sure that the entry.dir is the containing dir1871 // make sure that the entry.dir is the containing dir
1867 var entry_dir = try entry.dir.openDir(entry.basename, .{});1872 var entry_dir = try entry.dir.openDir(entry.basename, .{});
1868 defer entry_dir.close();1873 defer entry_dir.close();