diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 855cedbb..115ea4e4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,6 +9,8 @@ jobs: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main with: + linux_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]" + windows_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]" enable_wasm_sdk_build: true wasm_sdk_build_command: swift build -Xcc -D_WASI_EMULATED_PTHREAD diff --git a/Package.swift b/Package.swift index c82f577f..45c5abca 100644 --- a/Package.swift +++ b/Package.swift @@ -3,11 +3,13 @@ import PackageDescription import CompilerPluginSupport -// Availability Macros - let availabilityMacros: [SwiftSetting] = [ - .enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"), - .enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"), + .enableExperimentalFeature( + "AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0" + ), + .enableExperimentalFeature( + "AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0" + ), ] let package = Package( @@ -43,7 +45,39 @@ let package = Package( ), .testTarget( name: "AsyncAlgorithmsTests", - dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"], + dependencies: [ + .target(name: "AsyncAlgorithms"), + .target( + name: "AsyncSequenceValidation", + condition: .when(platforms: [ + .macOS, + .iOS, + .tvOS, + .watchOS, + .visionOS, + .macCatalyst, + .android, + .linux, + .openbsd, + .wasi, + ]) + ), + .target( + name: "AsyncAlgorithms_XCTest", + condition: .when(platforms: [ + .macOS, + .iOS, + .tvOS, + .watchOS, + .visionOS, + .macCatalyst, + .android, + .linux, + .openbsd, + .wasi, + ]) + ), + ], swiftSettings: availabilityMacros + [ .enableExperimentalFeature("StrictConcurrency=complete") ] @@ -53,7 +87,7 @@ let package = Package( if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { package.dependencies += [ - .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"), + .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0") ] } else { package.dependencies += [ diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift index b34c676a..8161e475 100644 --- a/Package@swift-5.8.swift +++ b/Package@swift-5.8.swift @@ -6,8 +6,12 @@ import CompilerPluginSupport // Availability Macros let availabilityMacros: [SwiftSetting] = [ - .enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"), - .enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"), + .enableExperimentalFeature( + "AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0" + ), + .enableExperimentalFeature( + "AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0" + ), ] let package = Package( @@ -43,7 +47,39 @@ let package = Package( ), .testTarget( name: "AsyncAlgorithmsTests", - dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"], + dependencies: [ + .target(name: "AsyncAlgorithms"), + .target( + name: "AsyncSequenceValidation", + condition: .when(platforms: [ + .macOS, + .iOS, + .tvOS, + .watchOS, + .visionOS, + .macCatalyst, + .android, + .linux, + .openbsd, + .wasi, + ]) + ), + .target( + name: "AsyncAlgorithms_XCTest", + condition: .when(platforms: [ + .macOS, + .iOS, + .tvOS, + .watchOS, + .visionOS, + .macCatalyst, + .android, + .linux, + .openbsd, + .wasi, + ]) + ), + ], swiftSettings: availabilityMacros + [ .enableExperimentalFeature("StrictConcurrency=complete") ] @@ -53,7 +89,7 @@ let package = Package( if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { package.dependencies += [ - .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"), + .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0") ] } else { package.dependencies += [ diff --git a/Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift b/Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift index adbee9f7..a966405e 100644 --- a/Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift +++ b/Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift @@ -80,7 +80,7 @@ public struct AsyncBufferSequence: AsyncSequence // to specify that the element is actually Sendable since the draining mechanism passes // through the isolation that is in nature sending but cannot be marked as such for the // isolated next method. - // In practice the users of this type are safe from isolation crossing since the Element + // In practice the users of this type are safe from isolation crossing since the Element // is as sendable as it is required by the base sequences the buffer is constructed from. enum StorageType { case transparent(Base.AsyncIterator) diff --git a/Sources/AsyncAlgorithms/Buffer/BoundedBufferStorage.swift b/Sources/AsyncAlgorithms/Buffer/BoundedBufferStorage.swift index 10eaa923..d9ae62ad 100644 --- a/Sources/AsyncAlgorithms/Buffer/BoundedBufferStorage.swift +++ b/Sources/AsyncAlgorithms/Buffer/BoundedBufferStorage.swift @@ -109,7 +109,6 @@ final class BoundedBufferStorage: Sendable where Base: Send case .none: break case .resumeConsumer(let continuation, let result): - continuation.resume(returning: result) } } diff --git a/Tests/AsyncAlgorithmsTests/TestBuffer.swift b/Tests/AsyncAlgorithmsTests/TestBuffer.swift index 83026953..42dd2f1a 100644 --- a/Tests/AsyncAlgorithmsTests/TestBuffer.swift +++ b/Tests/AsyncAlgorithmsTests/TestBuffer.swift @@ -108,6 +108,7 @@ final class TestBuffer: XCTestCase { XCTAssertNil(pastFailure) } + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_given_a_base_sequence_when_bufferingOldest_then_the_policy_is_applied() async { validate { "X-12- 34- 5 |" @@ -171,6 +172,7 @@ final class TestBuffer: XCTestCase { "X,,,,,,[45^]" } } + #endif func test_given_a_buffered_with_unbounded_sequence_when_cancelling_consumer_then_the_iteration_finishes_and_the_base_is_cancelled() @@ -325,6 +327,7 @@ final class TestBuffer: XCTestCase { await fulfillment(of: [finished], timeout: 1.0) } + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_given_a_base_sequence_when_bounded_with_limit_0_then_the_policy_is_transparent() async { validate { "X-12- 34 -5|" @@ -332,4 +335,5 @@ final class TestBuffer: XCTestCase { "X-12- 34 -5|" } } + #endif } diff --git a/Tests/AsyncAlgorithmsTests/TestChunk.swift b/Tests/AsyncAlgorithmsTests/TestChunk.swift index 8cd5e8e8..b9a5956b 100644 --- a/Tests/AsyncAlgorithmsTests/TestChunk.swift +++ b/Tests/AsyncAlgorithmsTests/TestChunk.swift @@ -10,6 +10,9 @@ //===----------------------------------------------------------------------===// import XCTest + +#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) + import AsyncSequenceValidation import AsyncAlgorithms @@ -334,3 +337,5 @@ final class TestChunk: XCTestCase { } } } + +#endif diff --git a/Tests/AsyncAlgorithmsTests/TestDebounce.swift b/Tests/AsyncAlgorithmsTests/TestDebounce.swift index 317f0bca..94dae286 100644 --- a/Tests/AsyncAlgorithmsTests/TestDebounce.swift +++ b/Tests/AsyncAlgorithmsTests/TestDebounce.swift @@ -13,6 +13,7 @@ import XCTest import AsyncAlgorithms final class TestDebounce: XCTestCase { + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_delayingValues() throws { guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else { throw XCTSkip("Skipped due to Clock/Instant/Duration availability") @@ -67,6 +68,7 @@ final class TestDebounce: XCTestCase { "----|" } } + #endif func test_Rethrows() async throws { guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else { diff --git a/Tests/AsyncAlgorithmsTests/TestMerge.swift b/Tests/AsyncAlgorithmsTests/TestMerge.swift index a2779e3d..03650ec4 100644 --- a/Tests/AsyncAlgorithmsTests/TestMerge.swift +++ b/Tests/AsyncAlgorithmsTests/TestMerge.swift @@ -170,6 +170,7 @@ final class TestMerge2: XCTestCase { XCTAssertEqual(collected.intersection(expected), expected) } + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_merge_makes_sequence_with_ordered_elements_when_sources_follow_a_timeline() { validate { "a-c-e-g-|" @@ -178,6 +179,7 @@ final class TestMerge2: XCTestCase { "abcdefgh|" } } + #endif func test_merge_finishes_when_iteration_task_is_cancelled() async { let source1 = Indefinite(value: "test1") @@ -508,6 +510,7 @@ final class TestMerge3: XCTestCase { XCTAssertEqual(collected.intersection(expected), expected) } + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_merge_makes_sequence_with_ordered_elements_when_sources_follow_a_timeline() { validate { "a---e---|" @@ -517,6 +520,7 @@ final class TestMerge3: XCTestCase { "abcdefgh|" } } + #endif func test_merge_finishes_when_iteration_task_is_cancelled() async { let source1 = Indefinite(value: "test1") diff --git a/Tests/AsyncAlgorithmsTests/TestThrottle.swift b/Tests/AsyncAlgorithmsTests/TestThrottle.swift index bf027233..0d21cd5a 100644 --- a/Tests/AsyncAlgorithmsTests/TestThrottle.swift +++ b/Tests/AsyncAlgorithmsTests/TestThrottle.swift @@ -13,6 +13,7 @@ import XCTest import AsyncAlgorithms final class TestThrottle: XCTestCase { + #if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) func test_rate_0() throws { guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else { throw XCTSkip("Skipped due to Clock/Instant/Duration availability") @@ -188,4 +189,5 @@ final class TestThrottle: XCTestCase { "a--d--g--j--[l|]" } } + #endif } diff --git a/Tests/AsyncAlgorithmsTests/TestTimer.swift b/Tests/AsyncAlgorithmsTests/TestTimer.swift index b54647ca..05160097 100644 --- a/Tests/AsyncAlgorithmsTests/TestTimer.swift +++ b/Tests/AsyncAlgorithmsTests/TestTimer.swift @@ -10,6 +10,9 @@ //===----------------------------------------------------------------------===// import XCTest + +#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) + import AsyncAlgorithms import AsyncSequenceValidation @@ -57,3 +60,5 @@ final class TestTimer: XCTestCase { } } } + +#endif diff --git a/Tests/AsyncAlgorithmsTests/TestValidationTests.swift b/Tests/AsyncAlgorithmsTests/TestValidationTests.swift index b4b646f2..f64dd2c5 100644 --- a/Tests/AsyncAlgorithmsTests/TestValidationTests.swift +++ b/Tests/AsyncAlgorithmsTests/TestValidationTests.swift @@ -10,6 +10,9 @@ //===----------------------------------------------------------------------===// import XCTest + +#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread) + import AsyncAlgorithms import AsyncSequenceValidation @testable import AsyncAlgorithms_XCTest @@ -354,3 +357,5 @@ struct LaggingAsyncSequence: AsyncSequence { self.clock = clock } } + +#endif