Skip to content

Commit

Permalink
Tests: replace sleep with Thread.sleep(forTimeInterval:) (#616)
Browse files Browse the repository at this point in the history
`sleep` is not portable as it is not a standard C function.  Use the
Foundation function to provide a single codepath across all the targets.
  • Loading branch information
compnerd authored Jun 12, 2023
1 parent 7eac767 commit 55f84fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Tests/SwiftDocCTests/Utility/SynchronizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SynchronizationTests: XCTestCase {

// Schedule the synchronized block of work asynchronously
testQueue.async {
synced.sync { _ in _ = sleep(5) }
synced.sync { _ in Thread.sleep(forTimeInterval: 5) }
}

// Asynchronously perform a check after 0.25 secs that the lock is locked
Expand Down Expand Up @@ -112,7 +112,7 @@ class SynchronizationTests: XCTestCase {
// Block the access for a second, then update to `true`
testQueue.async {
synced.sync {
_ = sleep(1)
Thread.sleep(forTimeInterval: 1)
$0 = true
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ class SynchronizationTests: XCTestCase {
// Block the access for a second, then update to `true`
testQueue.async {
synced.sync {
_ = sleep(5)
Thread.sleep(forTimeInterval: 5)
value = true
}
}
Expand Down

0 comments on commit 55f84fa

Please sign in to comment.