| ... | @@ -20,6 +20,28 @@ const expectEqualStrings = std.testing.expectEqualStrings; | ... | @@ -20,6 +20,28 @@ const expectEqualStrings = std.testing.expectEqualStrings; |
| 20 | const expectError = std.testing.expectError; | 20 | const expectError = std.testing.expectError; |
| 21 | const tmpDir = std.testing.tmpDir; | 21 | const tmpDir = std.testing.tmpDir; |
| 22 | | 22 | |
| | 23 | // This is kept in sync with Io.Threaded.realPath . |
| | 24 | pub inline fn isRealPathSupported() bool { |
| | 25 | return switch (native_os) { |
| | 26 | .windows, |
| | 27 | .driverkit, |
| | 28 | .ios, |
| | 29 | .maccatalyst, |
| | 30 | .macos, |
| | 31 | .tvos, |
| | 32 | .visionos, |
| | 33 | .watchos, |
| | 34 | .linux, |
| | 35 | .serenity, |
| | 36 | .illumos, |
| | 37 | .freebsd, |
| | 38 | => true, |
| | 39 | .dragonfly => builtin.os.version_range.semver.min.order(.{ .major = 6, .minor = 0, .patch = 0 }) != .lt, |
| | 40 | .netbsd => builtin.os.version_range.semver.min.order(.{ .major = 10, .minor = 0, .patch = 0 }) != .lt, |
| | 41 | else => false, |
| | 42 | }; |
| | 43 | } |
| | 44 | |
| 23 | const PathType = enum { | 45 | const PathType = enum { |
| 24 | relative, | 46 | relative, |
| 25 | absolute, | 47 | absolute, |
| ... | @@ -28,25 +50,7 @@ const PathType = enum { | ... | @@ -28,25 +50,7 @@ const PathType = enum { |
| 28 | fn isSupported(self: PathType, target_os: std.Target.Os) bool { | 50 | fn isSupported(self: PathType, target_os: std.Target.Os) bool { |
| 29 | return switch (self) { | 51 | return switch (self) { |
| 30 | .relative => true, | 52 | .relative => true, |
| 31 | .absolute => switch (target_os.tag) { | 53 | .absolute => isRealPathSupported(), |
| 32 | .windows, | | |
| 33 | .driverkit, | | |
| 34 | .ios, | | |
| 35 | .maccatalyst, | | |
| 36 | .macos, | | |
| 37 | .tvos, | | |
| 38 | .visionos, | | |
| 39 | .watchos, | | |
| 40 | .linux, | | |
| 41 | .illumos, | | |
| 42 | .freebsd, | | |
| 43 | .serenity, | | |
| 44 | => true, | | |
| 45 | | | |
| 46 | .dragonfly => target_os.version_range.semver.max.order(.{ .major = 6, .minor = 0, .patch = 0 }) != .lt, | | |
| 47 | .netbsd => target_os.version_range.semver.max.order(.{ .major = 10, .minor = 0, .patch = 0 }) != .lt, | | |
| 48 | else => false, | | |
| 49 | }, | | |
| 50 | .unc => target_os.tag == .windows, | 54 | .unc => target_os.tag == .windows, |
| 51 | }; | 55 | }; |
| 52 | } | 56 | } |
| ... | @@ -314,8 +318,7 @@ test "openDir" { | ... | @@ -314,8 +318,7 @@ test "openDir" { |
| 314 | } | 318 | } |
| 315 | | 319 | |
| 316 | test "accessAbsolute" { | 320 | test "accessAbsolute" { |
| 317 | if (native_os == .wasi) return error.SkipZigTest; | 321 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 318 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 319 | | 322 | |
| 320 | const io = testing.io; | 323 | const io = testing.io; |
| 321 | const gpa = testing.allocator; | 324 | const gpa = testing.allocator; |
| ... | @@ -330,8 +333,7 @@ test "accessAbsolute" { | ... | @@ -330,8 +333,7 @@ test "accessAbsolute" { |
| 330 | } | 333 | } |
| 331 | | 334 | |
| 332 | test "openDirAbsolute" { | 335 | test "openDirAbsolute" { |
| 333 | if (native_os == .wasi) return error.SkipZigTest; | 336 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 334 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 335 | | 337 | |
| 336 | const io = testing.io; | 338 | const io = testing.io; |
| 337 | const gpa = testing.allocator; | 339 | const gpa = testing.allocator; |
| ... | @@ -428,8 +430,7 @@ test "openDir non-cwd parent '..'" { | ... | @@ -428,8 +430,7 @@ test "openDir non-cwd parent '..'" { |
| 428 | } | 430 | } |
| 429 | | 431 | |
| 430 | test "readLinkAbsolute" { | 432 | test "readLinkAbsolute" { |
| 431 | if (native_os == .wasi) return error.SkipZigTest; | 433 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 432 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 433 | | 434 | |
| 434 | const io = testing.io; | 435 | const io = testing.io; |
| 435 | | 436 | |
| ... | @@ -645,8 +646,7 @@ fn contains(entries: *const std.array_list.Managed(Dir.Entry), el: Dir.Entry) bo | ... | @@ -645,8 +646,7 @@ fn contains(entries: *const std.array_list.Managed(Dir.Entry), el: Dir.Entry) bo |
| 645 | } | 646 | } |
| 646 | | 647 | |
| 647 | test "Dir.realPath smoke test" { | 648 | test "Dir.realPath smoke test" { |
| 648 | if (native_os == .wasi) return error.SkipZigTest; | 649 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 649 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 650 | | 650 | |
| 651 | try testWithAllSupportedPathTypes(struct { | 651 | try testWithAllSupportedPathTypes(struct { |
| 652 | fn impl(ctx: *TestContext) !void { | 652 | fn impl(ctx: *TestContext) !void { |
| ... | @@ -1074,8 +1074,7 @@ test "rename" { | ... | @@ -1074,8 +1074,7 @@ test "rename" { |
| 1074 | } | 1074 | } |
| 1075 | | 1075 | |
| 1076 | test "renameAbsolute" { | 1076 | test "renameAbsolute" { |
| 1077 | if (native_os == .wasi) return error.SkipZigTest; | 1077 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 1078 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 1079 | | 1078 | |
| 1080 | const io = testing.io; | 1079 | const io = testing.io; |
| 1081 | | 1080 | |
| ... | @@ -2029,8 +2028,7 @@ test "'.' and '..' in Dir functions" { | ... | @@ -2029,8 +2028,7 @@ test "'.' and '..' in Dir functions" { |
| 2029 | } | 2028 | } |
| 2030 | | 2029 | |
| 2031 | test "'.' and '..' in absolute functions" { | 2030 | test "'.' and '..' in absolute functions" { |
| 2032 | if (native_os == .wasi) return error.SkipZigTest; | 2031 | if (!isRealPathSupported()) return error.SkipZigTest; |
| 2033 | if (native_os == .openbsd) return error.SkipZigTest; | | |
| 2034 | | 2032 | |
| 2035 | const io = testing.io; | 2033 | const io = testing.io; |
| 2036 | | 2034 | |