Skip to content

Commit 61dfb63

Browse files
committed
Fix waitUntil ignore AsyncDefaults.Timeout value
1 parent 35dda35 commit 61dfb63

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/Nimble/DSL+Wait.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterv
111111
///
112112
/// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function
113113
/// is executing. Any attempts to touch the run loop may cause non-deterministic behavior.
114-
public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
114+
public func waitUntil(timeout: TimeInterval = AsyncDefaults.Timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
115115
NMBWait.until(timeout: timeout, file: file, line: line, action: action)
116116
}

Tests/NimbleTests/AsynchronousTest.swift

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider {
88
return [
99
("testToEventuallyPositiveMatches", testToEventuallyPositiveMatches),
1010
("testToEventuallyNegativeMatches", testToEventuallyNegativeMatches),
11+
("testWaitUntilWithCustomDefaultsTimeout", testWaitUntilWithCustomDefaultsTimeout),
1112
("testWaitUntilPositiveMatches", testWaitUntilPositiveMatches),
1213
("testToEventuallyWithCustomDefaultTimeout", testToEventuallyWithCustomDefaultTimeout),
1314
("testWaitUntilTimesOutIfNotCalled", testWaitUntilTimesOutIfNotCalled),
@@ -85,6 +86,17 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider {
8586
}
8687
expect { value }.toEventuallyNot(equal(1))
8788
}
89+
90+
func testWaitUntilWithCustomDefaultsTimeout() {
91+
AsyncDefaults.Timeout = 5
92+
defer {
93+
AsyncDefaults.Timeout = 1
94+
}
95+
waitUntil() { done in
96+
Thread.sleep(forTimeInterval: 4.8)
97+
done()
98+
}
99+
}
88100

89101
func testWaitUntilPositiveMatches() {
90102
waitUntil { done in

0 commit comments

Comments
 (0)