diff --git a/Package.resolved b/Package.resolved index 89de3670..c8d1e356 100644 --- a/Package.resolved +++ b/Package.resolved @@ -18,6 +18,15 @@ "version" : "1.0.3" } }, + { + "identity" : "swift-concurrency-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-concurrency-extras", + "state" : { + "revision" : "ecb065a41bbdd7f64ab2695ffc755ed37c9ff4dc", + "version" : "0.1.0" + } + }, { "identity" : "swift-docc-plugin", "kind" : "remoteSourceControl", @@ -32,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "f821dcbac7cb6913f8e0d1a80496d0ba0199fa81", - "version" : "0.3.0" + "revision" : "4af50b38daf0037cfbab15514a241224c3f62f98", + "version" : "0.8.5" } } ], diff --git a/Package.swift b/Package.swift index 732a57cf..358ed87a 100644 --- a/Package.swift +++ b/Package.swift @@ -19,15 +19,17 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.3.0"), .package(url: "https://github.com/apple/swift-async-algorithms", revision: "cf70e78"), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "0.1.0"), + .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.8.0"), ], targets: [ .target( name: "Clocks", dependencies: [ - .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay") + .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"), + .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), ] ), .testTarget( diff --git a/Sources/Clocks/ImmediateClock.swift b/Sources/Clocks/ImmediateClock.swift index 529cf414..31815308 100644 --- a/Sources/Clocks/ImmediateClock.swift +++ b/Sources/Clocks/ImmediateClock.swift @@ -1,4 +1,5 @@ #if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) + import ConcurrencyExtras import Foundation /// A clock that does not suspend when sleeping. diff --git a/Sources/Clocks/Internal/Yield.swift b/Sources/Clocks/Internal/Yield.swift deleted file mode 100644 index e82fe03f..00000000 --- a/Sources/Clocks/Internal/Yield.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Foundation - -extension Task where Success == Failure, Failure == Never { - // NB: We would love if this was not necessary. See this forum post for more information: - // https://forums.swift.org/t/reliably-testing-code-that-adopts-swift-concurrency/57304 - static func megaYield(count: Int = defaultMegaYieldCount) async { - for _ in 0...detached(priority: .background) { await Task.yield() }.value - } - } -} - -let defaultMegaYieldCount = max( - 0, - min( - ProcessInfo.processInfo.environment["TASK_MEGA_YIELD_COUNT"].flatMap(Int.init) ?? 20, - 10_000 - ) -) diff --git a/Sources/Clocks/Shims.swift b/Sources/Clocks/Shims.swift index 7e82b4a9..5737704d 100644 --- a/Sources/Clocks/Shims.swift +++ b/Sources/Clocks/Shims.swift @@ -1,4 +1,4 @@ -#if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) +#if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) && swift(<5.9) @available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) extension Clock { /// Suspends for the given duration. diff --git a/Sources/Clocks/TestClock.swift b/Sources/Clocks/TestClock.swift index 02db0a37..c2a19abe 100644 --- a/Sources/Clocks/TestClock.swift +++ b/Sources/Clocks/TestClock.swift @@ -1,4 +1,5 @@ #if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) + import ConcurrencyExtras import Foundation import XCTestDynamicOverlay diff --git a/Sources/Clocks/UnimplementedClock.swift b/Sources/Clocks/UnimplementedClock.swift index 6fb0bcf9..5b5a210a 100644 --- a/Sources/Clocks/UnimplementedClock.swift +++ b/Sources/Clocks/UnimplementedClock.swift @@ -1,4 +1,5 @@ #if swift(>=5.7) && (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst)) + import ConcurrencyExtras import Foundation import XCTestDynamicOverlay