| ... | ... | @@ -703,6 +703,44 @@ test "makePath in a directory that no longer exists" { |
| 703 | 703 | try testing.expectError(error.FileNotFound, tmp.dir.makePath("sub-path")); |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | fn testFilenameLimits(iterable_dir: IterableDir, maxed_filename: []const u8) !void { |
| 707 | // setup, create a dir and a nested file both with maxed filenames, and walk the dir |
| 708 | { |
| 709 | var maxed_dir = try iterable_dir.dir.makeOpenPath(maxed_filename, .{}); |
| 710 | defer maxed_dir.close(); |
| 711 | |
| 712 | try maxed_dir.writeFile(maxed_filename, ""); |
| 713 | |
| 714 | var walker = try iterable_dir.walk(testing.allocator); |
| 715 | defer walker.deinit(); |
| 716 | |
| 717 | var count: usize = 0; |
| 718 | while (try walker.next()) |entry| { |
| 719 | try testing.expectEqualStrings(maxed_filename, entry.basename); |
| 720 | count += 1; |
| 721 | } |
| 722 | try testing.expectEqual(@as(usize, 2), count); |
| 723 | } |
| 724 | |
| 725 | // ensure that we can delete the tree |
| 726 | try iterable_dir.dir.deleteTree(maxed_filename); |
| 727 | } |
| 728 | |
| 729 | test "filename limits" { |
| 730 | var tmp = tmpIterableDir(.{}); |
| 731 | defer tmp.cleanup(); |
| 732 | |
| 733 | if (builtin.os.tag == .windows) { |
| 734 | // € is the character with the largest codepoint that is encoded as a single u16 in UTF-16, |
| 735 | // so Windows allows for NAME_MAX of them |
| 736 | const maxed_windows_filename = ("€".*) ** std.os.windows.NAME_MAX; |
| 737 | try testFilenameLimits(tmp.iterable_dir, &maxed_windows_filename); |
| 738 | } else { |
| 739 | const maxed_ascii_filename = [_]u8{'1'} ** std.fs.MAX_NAME_BYTES; |
| 740 | try testFilenameLimits(tmp.iterable_dir, &maxed_ascii_filename); |
| 741 | } |
| 742 | } |
| 743 | |
| 706 | 744 | test "writev, readv" { |
| 707 | 745 | var tmp = tmpDir(.{}); |
| 708 | 746 | defer tmp.cleanup(); |