| ... | @@ -341,6 +341,8 @@ test "Dir.realpath smoke test" { | ... | @@ -341,6 +341,8 @@ test "Dir.realpath smoke test" { |
| 341 | // with a sharing violation. | 341 | // with a sharing violation. |
| 342 | file.close(); | 342 | file.close(); |
| 343 | | 343 | |
| | 344 | try tmp_dir.dir.makeDir("test_dir"); |
| | 345 | |
| 344 | var arena = ArenaAllocator.init(testing.allocator); | 346 | var arena = ArenaAllocator.init(testing.allocator); |
| 345 | defer arena.deinit(); | 347 | defer arena.deinit(); |
| 346 | const allocator = arena.allocator(); | 348 | const allocator = arena.allocator(); |
| ... | @@ -353,18 +355,25 @@ test "Dir.realpath smoke test" { | ... | @@ -353,18 +355,25 @@ test "Dir.realpath smoke test" { |
| 353 | // First, test non-alloc version | 355 | // First, test non-alloc version |
| 354 | { | 356 | { |
| 355 | var buf1: [fs.MAX_PATH_BYTES]u8 = undefined; | 357 | var buf1: [fs.MAX_PATH_BYTES]u8 = undefined; |
| | 358 | |
| 356 | const file_path = try tmp_dir.dir.realpath("test_file", buf1[0..]); | 359 | const file_path = try tmp_dir.dir.realpath("test_file", buf1[0..]); |
| 357 | const expected_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_file" }); | 360 | const expected_file_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_file" }); |
| | 361 | try testing.expectEqualStrings(expected_file_path, file_path); |
| 358 | | 362 | |
| 359 | try testing.expect(mem.eql(u8, file_path, expected_path)); | 363 | const dir_path = try tmp_dir.dir.realpath("test_dir", buf1[0..]); |
| | 364 | const expected_dir_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_dir" }); |
| | 365 | try testing.expectEqualStrings(expected_dir_path, dir_path); |
| 360 | } | 366 | } |
| 361 | | 367 | |
| 362 | // Next, test alloc version | 368 | // Next, test alloc version |
| 363 | { | 369 | { |
| 364 | const file_path = try tmp_dir.dir.realpathAlloc(allocator, "test_file"); | 370 | const file_path = try tmp_dir.dir.realpathAlloc(allocator, "test_file"); |
| 365 | const expected_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_file" }); | 371 | const expected_file_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_file" }); |
| | 372 | try testing.expectEqualStrings(expected_file_path, file_path); |
| 366 | | 373 | |
| 367 | try testing.expect(mem.eql(u8, file_path, expected_path)); | 374 | const dir_path = try tmp_dir.dir.realpathAlloc(allocator, "test_dir"); |
| | 375 | const expected_dir_path = try fs.path.join(allocator, &[_][]const u8{ base_path, "test_dir" }); |
| | 376 | try testing.expectEqualStrings(expected_dir_path, dir_path); |
| 368 | } | 377 | } |
| 369 | } | 378 | } |
| 370 | | 379 | |