Skip to content

Commit f86dd9d

Browse files
committed
FoundationEssentialTests: nanosleep is not portable, avoid it
Use `Thread.sleep(forTimeInterval:)` instead of `nanosleep` which is not a portable sleep primitive. This allows us to build the package tests on Windows.
1 parent e07817c commit f86dd9d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Tests/FoundationEssentialsTests/ProcessInfoTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ final class ProcessInfoTests : XCTestCase {
9999
XCTAssertTrue(
100100
now > 1, "ProcessInfo returned an unrealistically low system uptime")
101101
// Sleep for 0.1s
102-
var ts: timespec = timespec(tv_sec: 0, tv_nsec: 100000000)
103-
nanosleep(&ts, nil)
102+
Task.sleep(for: .milliseconds(1000))
104103
XCTAssertTrue(
105104
ProcessInfo.processInfo.systemUptime > now,
106105
"ProcessInfo returned the same system uptime with 400")

0 commit comments

Comments
 (0)