@@ -81,7 +81,6 @@ private struct StatTests {
8181 }
8282
8383 @Test
84- @available ( macOS 13 . 0 , iOS 16 . 0 , watchOS 9 . 0 , tvOS 16 . 0 , * )
8584 func followSymlinkInits( ) async throws {
8685 try withTemporaryFilePath ( basename: " Stat_followSymlinkInits " ) { tempDir in
8786 let targetFilePath = tempDir. appending ( " target.txt " )
@@ -98,17 +97,15 @@ private struct StatTests {
9897 }
9998 }
10099
101- #if !os(WASI) // Can't open an fd to a symlink on WASI (no O_PATH)
100+ // Can't open an fd to a symlink on WASI (no O_PATH)
101+ // On non-Darwin, we need O_PATH | O_NOFOLLOW to open the symlink
102+ // directly, but O_PATH requires _GNU_SOURCE be defined (TODO).
102103 #if SYSTEM_PACKAGE_DARWIN
103104 let symlinkFD = try FileDescriptor . open ( symlinkPath, . readOnly, options: . symlink)
104- #else
105- // Need O_PATH | O_NOFOLLOW to open the symlink directly
106- let symlinkFD = try FileDescriptor . open ( symlinkPath, . readOnly, options: [ . path, . noFollow] )
107- #endif
108105 defer {
109106 try ? symlinkFD. close ( )
110107 }
111- #endif // !os(WASI)
108+ #endif
112109
113110 let targetStat = try targetFilePath. stat ( )
114111 let originalTargetAccessTime = targetStat. st_atim
@@ -130,7 +127,7 @@ private struct StatTests {
130127 stat. st_atim = originalTargetAccessTime
131128 #expect( stat == targetStat)
132129
133- #if !os(WASI)
130+ #if SYSTEM_PACKAGE_DARWIN
134131 stat = try symlinkFD. stat ( )
135132 stat. st_atim = originalSymlinkAccessTime
136133 #expect( stat == symlinkStat)
@@ -142,7 +139,7 @@ private struct StatTests {
142139 stat. st_atim = originalTargetAccessTime
143140 #expect( stat == targetStat)
144141
145- #if !os(WASI)
142+ #if SYSTEM_PACKAGE_DARWIN
146143 stat = try Stat ( symlinkFD)
147144 stat. st_atim = originalSymlinkAccessTime
148145 #expect( stat == symlinkStat)
@@ -400,11 +397,12 @@ private struct StatTests {
400397
401398}
402399
403- #if !SYSTEM_PACKAGE_DARWIN && !os(WASI)
404- private extension FileDescriptor . OpenOptions {
405- static var path : Self { Self ( rawValue: O_PATH) }
406- }
407- #endif
400+ // TODO: Re-enable for testing when _GNU_SOURCE can be defined.
401+ //#if !SYSTEM_PACKAGE_DARWIN && !os(WASI)
402+ //private extension FileDescriptor.OpenOptions {
403+ // static var path: Self { Self(rawValue: O_PATH) }
404+ //}
405+ //#endif
408406
409407// Comparison operators for timespec until UTCClock.Instant properties are available
410408private func >= ( lhs: timespec , rhs: timespec ) -> Bool {
0 commit comments