authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-12-19 03:15:37-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:10-08:00
logb6cde023225de9a164fc5e43ddc04551934cf6e9
tree43f3150373357e594847b5cd148bb6cad825f451
parentf96ef9780a4604316ff9bcb5cc2f0775c0de5c79

fs tests: Remove references to readLinkW which no longer exists


1 files changed, 4 insertions(+), 23 deletions(-)

lib/std/fs/test.zig+4-23
......@@ -218,16 +218,10 @@ test "Dir.readLink" {
218218 // test 1: symlink to a file
219219 try setupSymlink(io, ctx.dir, file_target_path, "symlink1", .{});
220220 try testReadLink(io, ctx.dir, canonical_file_target_path, "symlink1");
221 if (builtin.os.tag == .windows) {
222 try testReadLinkW(testing.allocator, ctx.dir, canonical_file_target_path, "symlink1");
223 }
224221
225222 // test 2: symlink to a directory (can be different on Windows)
226223 try setupSymlink(io, ctx.dir, dir_target_path, "symlink2", .{ .is_directory = true });
227224 try testReadLink(io, ctx.dir, canonical_dir_target_path, "symlink2");
228 if (builtin.os.tag == .windows) {
229 try testReadLinkW(testing.allocator, ctx.dir, canonical_dir_target_path, "symlink2");
230 }
231225
232226 // test 3: relative path symlink
233227 const parent_file = ".." ++ Dir.path.sep_str ++ "target.txt";
......@@ -236,9 +230,6 @@ test "Dir.readLink" {
236230 defer subdir.close(io);
237231 try setupSymlink(io, subdir, canonical_parent_file, "relative-link.txt", .{});
238232 try testReadLink(io, subdir, canonical_parent_file, "relative-link.txt");
239 if (builtin.os.tag == .windows) {
240 try testReadLinkW(testing.allocator, subdir, canonical_parent_file, "relative-link.txt");
241 }
242233 }
243234 }.impl);
244235}
......@@ -275,17 +266,6 @@ fn testReadLink(io: Io, dir: Dir, target_path: []const u8, symlink_path: []const
275266 try expectEqualStrings(target_path, actual);
276267}
277268
278fn testReadLinkW(allocator: Allocator, dir: Dir, target_path: []const u8, symlink_path: []const u8) !void {
279 const target_path_w = try std.unicode.wtf8ToWtf16LeAlloc(allocator, target_path);
280 defer allocator.free(target_path_w);
281 // Calling the W functions directly requires the path to be NT-prefixed
282 const symlink_path_w = try std.os.windows.sliceToPrefixedFileW(dir.handle, symlink_path);
283 const wtf16_buffer = try allocator.alloc(u16, target_path_w.len);
284 defer allocator.free(wtf16_buffer);
285 const actual = try dir.readLinkW(symlink_path_w.span(), wtf16_buffer);
286 try expectEqualSlices(u16, target_path_w, actual);
287}
288
289269fn testReadLinkAbsolute(io: Io, target_path: []const u8, symlink_path: []const u8) !void {
290270 var buffer: [Dir.max_path_bytes]u8 = undefined;
291271 const given = buffer[0..try Dir.readLinkAbsolute(io, symlink_path, &buffer)];
......@@ -2153,6 +2133,7 @@ test "invalid UTF-8/WTF-8 paths" {
21532133 try expectError(expected_err, Dir.rename(ctx.dir, invalid_path, ctx.dir, invalid_path, io));
21542134
21552135 if (native_os != .wasi and ctx.path_type != .relative) {
2136 var buf: [Dir.max_path_bytes]u8 = undefined;
21562137 try expectError(expected_err, Dir.copyFileAbsolute(invalid_path, invalid_path, io, .{}));
21572138 try expectError(expected_err, Dir.makeDirAbsolute(io, invalid_path, .default_dir));
21582139 try expectError(expected_err, Dir.deleteDirAbsolute(io, invalid_path));
......@@ -2162,10 +2143,10 @@ test "invalid UTF-8/WTF-8 paths" {
21622143 try expectError(expected_err, Dir.accessAbsolute(io, invalid_path, .{}));
21632144 try expectError(expected_err, Dir.createFileAbsolute(io, invalid_path, .{}));
21642145 try expectError(expected_err, Dir.deleteFileAbsolute(io, invalid_path));
2165 var readlink_buf: [Dir.max_path_bytes]u8 = undefined;
2166 try expectError(expected_err, Dir.readLinkAbsolute(io, invalid_path, &readlink_buf));
2146 try expectError(expected_err, Dir.readLinkAbsolute(io, invalid_path, &buf));
21672147 try expectError(expected_err, Dir.symLinkAbsolute(io, invalid_path, invalid_path, .{}));
2168 try expectError(expected_err, Dir.realPathAbsoluteAlloc(io, invalid_path, testing.allocator));
2148 try expectError(expected_err, Dir.realPathFileAbsolute(io, invalid_path, &buf));
2149 try expectError(expected_err, Dir.realPathFileAbsoluteAlloc(io, invalid_path, testing.allocator));
21692150 }
21702151 }
21712152 }.impl);