| ... | ... | @@ -1765,14 +1765,14 @@ test "walker" { |
| 1765 | 1765 | |
| 1766 | 1766 | // iteration order of walker is undefined, so need lookup maps to check against |
| 1767 | 1767 | |
| 1768 | | const expected_paths = std.StaticStringMap(void).initComptime(.{ |
| 1769 | | .{"dir1"}, |
| 1770 | | .{"dir2"}, |
| 1771 | | .{"dir3"}, |
| 1772 | | .{"dir4"}, |
| 1773 | | .{"dir3" ++ fs.path.sep_str ++ "sub1"}, |
| 1774 | | .{"dir3" ++ fs.path.sep_str ++ "sub2"}, |
| 1775 | | .{"dir3" ++ fs.path.sep_str ++ "sub2" ++ fs.path.sep_str ++ "subsub1"}, |
| 1768 | const expected_paths = std.StaticStringMap(usize).initComptime(.{ |
| 1769 | .{ "dir1", 1 }, |
| 1770 | .{ "dir2", 1 }, |
| 1771 | .{ "dir3", 1 }, |
| 1772 | .{ "dir4", 1 }, |
| 1773 | .{ "dir3" ++ fs.path.sep_str ++ "sub1", 2 }, |
| 1774 | .{ "dir3" ++ fs.path.sep_str ++ "sub2", 2 }, |
| 1775 | .{ "dir3" ++ fs.path.sep_str ++ "sub2" ++ fs.path.sep_str ++ "subsub1", 3 }, |
| 1776 | 1776 | }); |
| 1777 | 1777 | |
| 1778 | 1778 | const expected_basenames = std.StaticStringMap(void).initComptime(.{ |
| ... | ... | @@ -1802,6 +1802,10 @@ test "walker" { |
| 1802 | 1802 | std.debug.print("found unexpected path: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)}); |
| 1803 | 1803 | return err; |
| 1804 | 1804 | }; |
| 1805 | testing.expectEqual(expected_paths.get(entry.path).?, entry.depth()) catch |err| { |
| 1806 | std.debug.print("path reported unexpected depth: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)}); |
| 1807 | return err; |
| 1808 | }; |
| 1805 | 1809 | // make sure that the entry.dir is the containing dir |
| 1806 | 1810 | var entry_dir = try entry.dir.openDir(entry.basename, .{}); |
| 1807 | 1811 | defer entry_dir.close(); |
| ... | ... | @@ -1851,6 +1855,10 @@ test "selective walker, skip entries that start with ." { |
| 1851 | 1855 | var num_walked: usize = 0; |
| 1852 | 1856 | while (try walker.next()) |entry| { |
| 1853 | 1857 | if (entry.basename[0] == '.') continue; |
| 1858 | if (entry.kind == .directory) { |
| 1859 | try walker.enter(entry); |
| 1860 | } |
| 1861 | |
| 1854 | 1862 | testing.expect(expected_basenames.has(entry.basename)) catch |err| { |
| 1855 | 1863 | std.debug.print("found unexpected basename: {f}\n", .{std.ascii.hexEscape(entry.basename, .lower)}); |
| 1856 | 1864 | return err; |
| ... | ... | @@ -1859,16 +1867,11 @@ test "selective walker, skip entries that start with ." { |
| 1859 | 1867 | std.debug.print("found unexpected path: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)}); |
| 1860 | 1868 | return err; |
| 1861 | 1869 | }; |
| 1862 | | |
| 1863 | | testing.expectEqual(expected_paths.get(entry.path).?, walker.depth()) catch |err| { |
| 1864 | | std.debug.print("path reported unexpected depth: {f}, {d}, expected {d}\n", .{ std.ascii.hexEscape(entry.path, .lower), walker.depth(), expected_paths.get(entry.path).? }); |
| 1870 | testing.expectEqual(expected_paths.get(entry.path).?, entry.depth()) catch |err| { |
| 1871 | std.debug.print("path reported unexpected depth: {f}\n", .{std.ascii.hexEscape(entry.path, .lower)}); |
| 1865 | 1872 | return err; |
| 1866 | 1873 | }; |
| 1867 | 1874 | |
| 1868 | | if (entry.kind == .directory) { |
| 1869 | | try walker.enter(entry); |
| 1870 | | } |
| 1871 | | |
| 1872 | 1875 | // make sure that the entry.dir is the containing dir |
| 1873 | 1876 | var entry_dir = try entry.dir.openDir(entry.basename, .{}); |
| 1874 | 1877 | defer entry_dir.close(); |