test(macos): guard FileHandle read APIs

This commit is contained in:
Peter Steinberger
2025-12-16 10:41:24 +01:00
parent 64d6d25d65
commit 66a0813e44
4 changed files with 215 additions and 3 deletions

View File

@@ -6,6 +6,15 @@ import Darwin
import Foundation
@Suite struct WebChatTunnelTests {
@Test func drainStderrDoesNotCrashWhenHandleClosed() {
let pipe = Pipe()
let handle = pipe.fileHandleForReading
try? handle.close()
let drained = WebChatTunnel._testDrainStderr(handle)
#expect(drained.isEmpty)
}
@Test func portIsFreeDetectsIPv4Listener() {
var fd = socket(AF_INET, SOCK_STREAM, 0)
#expect(fd >= 0)
@@ -57,7 +66,7 @@ import Foundation
free = true
break
}
usleep(10_000) // 10ms
usleep(10000) // 10ms
}
#expect(free == true)
}