mirror of
https://github.com/aculix/knotchy.git
synced 2026-10-27 07:15:53 +00:00
Initial release
This commit is contained in:
commit
4b67728cce
108 files changed
+13310
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import Testing
|
||||
|
||||
/// For work on other executors; controller timers run on the `TestClock` and never need it.
|
||||
@MainActor
|
||||
func waitUntil(
|
||||
_ description: String,
|
||||
timeout: Duration = .seconds(5),
|
||||
sourceLocation: SourceLocation = #_sourceLocation,
|
||||
_ condition: @MainActor () -> Bool
|
||||
) async {
|
||||
let deadline = ContinuousClock.now + timeout
|
||||
while !condition() {
|
||||
if ContinuousClock.now >= deadline {
|
||||
Issue.record("Timed out waiting until \(description)", sourceLocation: sourceLocation)
|
||||
return
|
||||
}
|
||||
do { try await Task.sleep(for: .milliseconds(1)) } catch { return }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user