diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f589536..0060a6b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: Build on: + pull_request: push: branches: - 'main' @@ -14,6 +15,7 @@ on: - 'style/**' - 'test/**' - 'tech/**' + - 'for-posterity/**' env: RUST_TARGET_PATH: pact-reference @@ -22,7 +24,7 @@ jobs: test: name: Run ${{ matrix.platform }} on ${{ matrix.host }} runs-on: ${{ matrix.host }} - + strategy: fail-fast: true matrix: diff --git a/Sources/Extensions/MockServer+Async.swift b/Sources/Extensions/MockServer+Async.swift index 2438dfa7..83c1ec45 100644 --- a/Sources/Extensions/MockServer+Async.swift +++ b/Sources/Extensions/MockServer+Async.swift @@ -18,15 +18,22 @@ import Foundation #if os(Linux) -import PactSwiftMockServerLinux + import PactSwiftMockServerLinux #elseif compiler(>=5.5) -@_implementationOnly import PactSwiftMockServer + @_implementationOnly import PactSwiftMockServer #else -import PactSwiftMockServer + import PactSwiftMockServer #endif extension MockServer { - + + // Handling platform specifics + #if os(Linux) + typealias TransferProtocolScheme = PactSwiftMockServerLinux.TransferProtocol + #else + private var TransferProtocolScheme = PactSwiftMockServer.TransferProtocol + #endif + /// Spins up a mock server with expected interactions defined in the provided Pact /// /// - Parameters: @@ -35,14 +42,14 @@ extension MockServer { /// @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) @discardableResult - func setup(pact: Data, protocol: PactSwiftMockServer.TransferProtocol = .standard) async throws -> Int { + func setup(pact: Data, protocol: TransferProtocolScheme = .standard) async throws -> Int { try await withCheckedThrowingContinuation { continuation in self.setup(pact: pact, protocol: `protocol`) { result in continuation.resume(with: result) } } } - + /// Verifies all interactions passed to mock server /// /// By default pact files are written to `/tmp/pacts`. @@ -56,7 +63,7 @@ extension MockServer { } } } - + /// Finalises Pact tests by writing the pact contract file to disk /// /// - Parameters: diff --git a/Sources/Extensions/Task+Timeout.swift b/Sources/Extensions/Task+Timeout.swift index 650f7616..d2dadaa0 100644 --- a/Sources/Extensions/Task+Timeout.swift +++ b/Sources/Extensions/Task+Timeout.swift @@ -19,7 +19,7 @@ import Foundation @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) extension Task where Failure == Error { - + // Start a new Task with a timeout. If the timeout expires before the operation is // completed then the task is cancelled and an error is thrown. @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) @@ -28,7 +28,11 @@ extension Task where Failure == Error { try await withThrowingTaskGroup(of: Success.self) { group -> Success in group.addTask(operation: operation) group.addTask { + #if os(Linux) + try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000)) + #else try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * Double(NSEC_PER_SEC))) + #endif throw TimeoutError(interval: timeout) } guard let success = try await group.next() else {