| ... | ... | @@ -1034,6 +1034,30 @@ test "walker" { |
| 1034 | 1034 | try testing.expectEqual(expected_paths.kvs.len, num_walked); |
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | test "walker without fully iterating" { |
| 1038 | if (builtin.os.tag == .wasi and builtin.link_libc) return error.SkipZigTest; |
| 1039 | if (builtin.os.tag == .wasi and !builtin.link_libc) try os.initPreopensWasi(std.heap.page_allocator, "/"); |
| 1040 | |
| 1041 | var tmp = tmpIterableDir(.{}); |
| 1042 | defer tmp.cleanup(); |
| 1043 | |
| 1044 | var walker = try tmp.iterable_dir.walk(testing.allocator); |
| 1045 | defer walker.deinit(); |
| 1046 | |
| 1047 | // Create 2 directories inside the tmp directory, but then only iterate once before breaking. |
| 1048 | // This ensures that walker doesn't try to close the initial directory when not fully iterating. |
| 1049 | |
| 1050 | try tmp.iterable_dir.dir.makePath("a"); |
| 1051 | try tmp.iterable_dir.dir.makePath("b"); |
| 1052 | |
| 1053 | var num_walked: usize = 0; |
| 1054 | while (try walker.next()) |_| { |
| 1055 | num_walked += 1; |
| 1056 | break; |
| 1057 | } |
| 1058 | try testing.expectEqual(@as(usize, 1), num_walked); |
| 1059 | } |
| 1060 | |
| 1037 | 1061 | test ". and .. in fs.Dir functions" { |
| 1038 | 1062 | if (builtin.os.tag == .wasi and builtin.link_libc) return error.SkipZigTest; |
| 1039 | 1063 | if (builtin.os.tag == .wasi and !builtin.link_libc) try os.initPreopensWasi(std.heap.page_allocator, "/"); |