File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Sources/ComposableArchitecture Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -2365,17 +2365,24 @@ class TestReducer<State, Action>: ReducerProtocol {
2365
2365
}
2366
2366
}
2367
2367
2368
- extension Task where Success == Never , Failure == Never {
2369
- // NB: We would love if this was not necessary, but due to a lack of async testing tools in Swift
2370
- // we're not sure if there is an alternative. See this forum post for more information:
2368
+ extension Task where Success == Failure , Failure == Never {
2369
+ // NB: We would love if this was not necessary. See this forum post for more information:
2371
2370
// https://forums.swift.org/t/reliably-testing-code-that-adopts-swift-concurrency/57304
2372
- @_spi ( Internals) public static func megaYield( count: Int = 10 ) async {
2373
- for _ in 1 ... count {
2371
+ @_spi ( Internals) public static func megaYield( count: Int = defaultMegaYieldCount ) async {
2372
+ for _ in 0 ..< count {
2374
2373
await Task < Void , Never > . detached ( priority: . background) { await Task . yield ( ) } . value
2375
2374
}
2376
2375
}
2377
2376
}
2378
2377
2378
+ @_spi ( Internals) public let defaultMegaYieldCount = max (
2379
+ 0 ,
2380
+ min (
2381
+ ProcessInfo . processInfo. environment [ " TASK_MEGA_YIELD_COUNT " ] . flatMap ( Int . init) ?? 20 ,
2382
+ 10_000
2383
+ )
2384
+ )
2385
+
2379
2386
// NB: Only needed until Xcode ships a macOS SDK that uses the 5.7 standard library.
2380
2387
// See: https://forums.swift.org/t/xcode-14-rc-cannot-specialize-protocol-type/60171/15
2381
2388
#if swift(>=5.7) && !os(macOS) && !targetEnvironment(macCatalyst)
You can’t perform that action at this time.
0 commit comments