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" {...@@ -218,16 +218,10 @@ test "Dir.readLink" {
218 // test 1: symlink to a file218 // test 1: symlink to a file
219 try setupSymlink(io, ctx.dir, file_target_path, "symlink1", .{});219 try setupSymlink(io, ctx.dir, file_target_path, "symlink1", .{});
220 try testReadLink(io, ctx.dir, canonical_file_target_path, "symlink1");220 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
225 // test 2: symlink to a directory (can be different on Windows)222 // test 2: symlink to a directory (can be different on Windows)
226 try setupSymlink(io, ctx.dir, dir_target_path, "symlink2", .{ .is_directory = true });223 try setupSymlink(io, ctx.dir, dir_target_path, "symlink2", .{ .is_directory = true });
227 try testReadLink(io, ctx.dir, canonical_dir_target_path, "symlink2");224 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
232 // test 3: relative path symlink226 // test 3: relative path symlink
233 const parent_file = ".." ++ Dir.path.sep_str ++ "target.txt";227 const parent_file = ".." ++ Dir.path.sep_str ++ "target.txt";
...@@ -236,9 +230,6 @@ test "Dir.readLink" {...@@ -236,9 +230,6 @@ test "Dir.readLink" {
236 defer subdir.close(io);230 defer subdir.close(io);
237 try setupSymlink(io, subdir, canonical_parent_file, "relative-link.txt", .{});231 try setupSymlink(io, subdir, canonical_parent_file, "relative-link.txt", .{});
238 try testReadLink(io, subdir, canonical_parent_file, "relative-link.txt");232 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 }
242 }233 }
243 }.impl);234 }.impl);
244}235}
...@@ -275,17 +266,6 @@ fn testReadLink(io: Io, dir: Dir, target_path: []const u8, symlink_path: []const...@@ -275,17 +266,6 @@ fn testReadLink(io: Io, dir: Dir, target_path: []const u8, symlink_path: []const
275 try expectEqualStrings(target_path, actual);266 try expectEqualStrings(target_path, actual);
276}267}
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
289fn testReadLinkAbsolute(io: Io, target_path: []const u8, symlink_path: []const u8) !void {269fn testReadLinkAbsolute(io: Io, target_path: []const u8, symlink_path: []const u8) !void {
290 var buffer: [Dir.max_path_bytes]u8 = undefined;270 var buffer: [Dir.max_path_bytes]u8 = undefined;
291 const given = buffer[0..try Dir.readLinkAbsolute(io, symlink_path, &buffer)];271 const given = buffer[0..try Dir.readLinkAbsolute(io, symlink_path, &buffer)];
...@@ -2153,6 +2133,7 @@ test "invalid UTF-8/WTF-8 paths" {...@@ -2153,6 +2133,7 @@ test "invalid UTF-8/WTF-8 paths" {
2153 try expectError(expected_err, Dir.rename(ctx.dir, invalid_path, ctx.dir, invalid_path, io));2133 try expectError(expected_err, Dir.rename(ctx.dir, invalid_path, ctx.dir, invalid_path, io));
21542134
2155 if (native_os != .wasi and ctx.path_type != .relative) {2135 if (native_os != .wasi and ctx.path_type != .relative) {
2136 var buf: [Dir.max_path_bytes]u8 = undefined;
2156 try expectError(expected_err, Dir.copyFileAbsolute(invalid_path, invalid_path, io, .{}));2137 try expectError(expected_err, Dir.copyFileAbsolute(invalid_path, invalid_path, io, .{}));
2157 try expectError(expected_err, Dir.makeDirAbsolute(io, invalid_path, .default_dir));2138 try expectError(expected_err, Dir.makeDirAbsolute(io, invalid_path, .default_dir));
2158 try expectError(expected_err, Dir.deleteDirAbsolute(io, invalid_path));2139 try expectError(expected_err, Dir.deleteDirAbsolute(io, invalid_path));
...@@ -2162,10 +2143,10 @@ test "invalid UTF-8/WTF-8 paths" {...@@ -2162,10 +2143,10 @@ test "invalid UTF-8/WTF-8 paths" {
2162 try expectError(expected_err, Dir.accessAbsolute(io, invalid_path, .{}));2143 try expectError(expected_err, Dir.accessAbsolute(io, invalid_path, .{}));
2163 try expectError(expected_err, Dir.createFileAbsolute(io, invalid_path, .{}));2144 try expectError(expected_err, Dir.createFileAbsolute(io, invalid_path, .{}));
2164 try expectError(expected_err, Dir.deleteFileAbsolute(io, invalid_path));2145 try expectError(expected_err, Dir.deleteFileAbsolute(io, invalid_path));
2165 var readlink_buf: [Dir.max_path_bytes]u8 = undefined;2146 try expectError(expected_err, Dir.readLinkAbsolute(io, invalid_path, &buf));
2166 try expectError(expected_err, Dir.readLinkAbsolute(io, invalid_path, &readlink_buf));
2167 try expectError(expected_err, Dir.symLinkAbsolute(io, invalid_path, invalid_path, .{}));2147 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));
2169 }2150 }
2170 }2151 }
2171 }.impl);2152 }.impl);