Skip to content

Commit ba19d45

Browse files
authored
Mark the sync versions of toEventually as nonasync, now that we require swift 5.7 (#1010)
1 parent 35eeb1c commit ba19d45

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Sources/Nimble/DSL+Wait.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: DispatchTi
116116
///
117117
/// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function
118118
/// is executing. Any attempts to touch the run loop may cause non-deterministic behavior.
119+
@available(*, noasync, message: "the sync version of `waitUntil` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
119120
public func waitUntil(timeout: DispatchTimeInterval = AsyncDefaults.timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
120121
NMBWait.until(timeout: timeout, file: file, line: line, action: action)
121122
}

Sources/Nimble/Polling.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extension SyncExpectation {
9999
/// @warning
100100
/// This form of `toEventually` does not work in any kind of async context. Use the async form of `toEventually` if you are running tests in an async context.
101101
@discardableResult
102+
@available(*, noasync, message: "the sync version of `toEventually` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
102103
public func toEventually(_ predicate: Predicate<Value>, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
103104
nimblePrecondition(expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue)
104105

@@ -131,6 +132,7 @@ extension SyncExpectation {
131132
/// This form of `toEventuallyNot` does not work in any kind of async context.
132133
/// Use the async form of `toEventuallyNot` if you are running tests in an async context.
133134
@discardableResult
135+
@available(*, noasync, message: "the sync version of `toEventuallyNot` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
134136
public func toEventuallyNot(_ predicate: Predicate<Value>, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
135137
nimblePrecondition(expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue)
136138

@@ -165,6 +167,7 @@ extension SyncExpectation {
165167
/// This form of `toNotEventually` does not work in any kind of async context.
166168
/// Use the async form of `toNotEventually` if you are running tests in an async context.
167169
@discardableResult
170+
@available(*, noasync, message: "the sync version of `toNotEventually` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
168171
public func toNotEventually(_ predicate: Predicate<Value>, timeout: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
169172
return toEventuallyNot(predicate, timeout: timeout, pollInterval: pollInterval, description: description)
170173
}
@@ -180,6 +183,7 @@ extension SyncExpectation {
180183
/// This form of `toNever` does not work in any kind of async context.
181184
/// Use the async form of `toNever` if you are running tests in an async context.
182185
@discardableResult
186+
@available(*, noasync, message: "the sync version of `toNever` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
183187
public func toNever(_ predicate: Predicate<Value>, until: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
184188
nimblePrecondition(expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue)
185189

@@ -214,6 +218,7 @@ extension SyncExpectation {
214218
/// This form of `neverTo` does not work in any kind of async context.
215219
/// Use the async form of `neverTo` if you are running tests in an async context.
216220
@discardableResult
221+
@available(*, noasync, message: "the sync version of `neverTo` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
217222
public func neverTo(_ predicate: Predicate<Value>, until: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
218223
return toNever(predicate, until: until, pollInterval: pollInterval, description: description)
219224
}
@@ -229,6 +234,7 @@ extension SyncExpectation {
229234
/// This form of `toAlways` does not work in any kind of async context.
230235
/// Use the async form of `toAlways` if you are running tests in an async context.
231236
@discardableResult
237+
@available(*, noasync, message: "the sync version of `toAlways` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
232238
public func toAlways(_ predicate: Predicate<Value>, until: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
233239
nimblePrecondition(expression.isClosure, "NimbleInternalError", toEventuallyRequiresClosureError.stringValue)
234240

@@ -263,6 +269,7 @@ extension SyncExpectation {
263269
/// This form of `alwaysTo` does not work in any kind of async context.
264270
/// Use the async form of `alwaysTo` if you are running tests in an async context.
265271
@discardableResult
272+
@available(*, noasync, message: "the sync version of `alwaysTo` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
266273
public func alwaysTo(_ predicate: Predicate<Value>, until: DispatchTimeInterval = AsyncDefaults.timeout, pollInterval: DispatchTimeInterval = AsyncDefaults.pollInterval, description: String? = nil) -> Self {
267274
return toAlways(predicate, until: until, pollInterval: pollInterval, description: description)
268275
}

0 commit comments

Comments
 (0)