From b2998d4f87e4ce7b83d9869833d598bd77017909 Mon Sep 17 00:00:00 2001 From: surpher Date: Fri, 4 Aug 2023 23:34:02 +1000 Subject: [PATCH] Remove support for Linux --- .github/workflows/build.yml | 136 +++----- .github/workflows/build_pr.yml | 130 +++---- Package.resolved | 15 +- Package.swift | 7 +- PactSwift.xcodeproj/project.pbxproj | 24 +- Scripts/build_rust_dependencies | 101 ------ Scripts/build_test_linux | 119 ------- Scripts/check_build_tools | 7 - Scripts/prepare_build_tools | 1 - Scripts/run_tests | 6 +- Sources/ExampleGenerators/DateTime.swift | 2 - .../DateTimeExpression.swift | 2 - Sources/ExampleGenerators/RandomBool.swift | 2 - Sources/ExampleGenerators/RandomDate.swift | 2 - .../ExampleGenerators/RandomDateTime.swift | 2 - Sources/ExampleGenerators/RandomDecimal.swift | 2 - .../ExampleGenerators/RandomHexadecimal.swift | 2 - Sources/ExampleGenerators/RandomInt.swift | 2 - Sources/ExampleGenerators/RandomString.swift | 6 +- Sources/ExampleGenerators/RandomTime.swift | 2 - Sources/ExampleGenerators/RandomUUID.swift | 2 - Sources/Extensions/MockServer+Async.swift | 2 +- Sources/Extensions/Task+Timeout.swift | 2 +- Sources/Matchers/DecimalLike.swift | 2 - Sources/Matchers/EachKeyLike.swift | 2 - Sources/Matchers/EachLike.swift | 2 - Sources/Matchers/EqualTo.swift | 2 - Sources/Matchers/FromProviderState.swift | 2 - Sources/Matchers/IncludesLike.swift | 2 - Sources/Matchers/IntegerLike.swift | 2 - Sources/Matchers/MatchNull.swift | 2 - Sources/Matchers/OneOf.swift | 2 - Sources/Matchers/RegexLike.swift | 2 - Sources/Matchers/SomethingLike.swift | 2 - Sources/MockService.swift | 22 +- Sources/Model/Interaction.swift | 22 -- Sources/Model/PactHTTPMethod.swift | 15 - Sources/Model/ProviderState.swift | 2 - Sources/Model/TransferProtocol.swift | 39 +-- Sources/PFMockService.swift | 8 +- Sources/ProviderVerifier.swift | 4 +- Sources/Toolbox/Logger.swift | 7 - .../ObjCExampleGeneratorTests.swift | 4 - Tests/Matchers/ObjCMatcherTests.swift | 4 - Tests/Model/MetadataTests.swift | 4 - Tests/Model/TransferProtocolTests.swift | 11 +- Tests/Services/AsyncMockServiceTests.swift | 3 +- Tests/Services/MockServiceTests.swift | 8 - .../MockServiceWithDirectoryPathTests.swift | 8 - Tests/Services/PFMockServiceTests.swift | 4 - Tests/Services/PactContractTests.swift | 318 +++++++++--------- Tests/Services/ProviderVerifierTests.swift | 4 +- 52 files changed, 297 insertions(+), 788 deletions(-) delete mode 100755 Scripts/build_rust_dependencies delete mode 100755 Scripts/build_test_linux diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f589536..a39fb7d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,135 +4,99 @@ on: push: branches: - 'main' - - 'chore/**' - - 'docs/**' - - 'feat/**' - - 'feature/**' - - 'fix/**' - - 'refactor/**' - - 'releases/**' - - 'style/**' - - 'test/**' - - 'tech/**' - -env: - RUST_TARGET_PATH: pact-reference jobs: - test: - name: Run ${{ matrix.platform }} on ${{ matrix.host }} + test_ios: + name: "๐Ÿค– Test iOS" runs-on: ${{ matrix.host }} - + strategy: fail-fast: true matrix: - host: [macos-11, macos-12] - platform: [ios, macos] + host: [macos-12, macos-13] include: - - platform: ios - scheme: "PactSwift-iOS" - destination: "platform=iOS Simulator,name=iPhone 12 Pro" - - platform: macos - scheme: "PactSwift-macOS" - destination: "arch=x86_64" - - host: macos-11 - xcode: 13.2.1 + - host: macos-13 + destination: "platform=iOS Simulator,name=iPhone 14 Pro" + xcode: '15.0' - host: macos-12 - xcode: 14.0.1 + destination: "platform=iOS Simulator,name=iPhone 12 Pro" + xcode: 14.1 env: - SCHEME: ${{ matrix.scheme }} + SCHEME: "PactSwift-iOS" DESTINATION: ${{ matrix.destination }} concurrency: - group: test_${{ matrix.host }}_${{ matrix.scheme }}_${{ github.ref }} + group: test_${{ matrix.host }}_${{ matrix.xcode }}_iOS_${{ github.ref }} cancel-in-progress: true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 - - name: Use Xcode ${{ matrix.xcode }} + - name: "๐Ÿญ Use Xcode ${{ matrix.xcode }}" run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app - - name: Prepare Tools + - name: "๐Ÿงฐ Prepare tools" run: | Scripts/prepare_build_tools - - name: Run tests (Xcode) + - name: "๐Ÿงช Run tests (xcodebuild)" run: | - set -o pipefail && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify + set -o pipefail && xcodebuild -resolvePackageDependencies && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify - - name: Run tests (CLI - Swift Package) + - name: "โš—๏ธ Run tests (swift)" run: | - swift build - swift test -c release - - test_linux: - name: Run on Ubuntu - runs-on: ubuntu-latest + set -o pipefail && swift test -c release + + test_macos: + name: "๐Ÿค– Test macOS" + runs-on: ${{ matrix.host }} strategy: fail-fast: true + matrix: + host: [macos-12, macos-13] + include: + - host: macos-13 + xcode: '15.0' + - host: macos-12 + xcode: 14.1 + + env: + SCHEME: "PactSwift-macOS" + DESTINATION: "arch=x86_64" concurrency: - group: test-linux-${{ github.ref }} + group: test_${{ matrix.host }}_${{ matrix.xcode }}_macOS_${{ github.ref }} cancel-in-progress: true steps: - - uses: fwal/setup-swift@v1 - - name: Get swift version - run: swift --version - - - name: "โฌ‡๏ธ Checkout repository" - uses: actions/checkout@v2 - - - name: Install Protoc - uses: arduino/setup-protoc@v1 - - - name: "โ™ผ Cache rust binaries" - uses: actions/cache@v3 - with: - path: | - ${{ env.RUST_TARGET_PATH }} - key: build-${{ runner.os }}-rust-pactswift-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - build-${{ runner.os }}-rust-pactswift - build-${{ runner.os }}-rust- - - - name: "โš—๏ธ Build and Test" - run: | - Scripts/build_test_linux + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 - test_carthage: - name: "Verify for Carthage" - runs-on: macos-12 - - strategy: - fail-fast: true - - concurrency: - group: test-carthage-${{ github.ref }} - cancel-in-progress: true + - name: "๐Ÿญ Use Xcode ${{ matrix.xcode }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app - steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿงฐ Prepare tools" + run: | + Scripts/prepare_build_tools - - name: Use Xcode 13.4.1 - run: sudo xcode-select -switch /Applications/Xcode_13.4.1.app + - name: "๐Ÿงช Run tests (xcodebuild)" + run: | + set -o pipefail && xcodebuild -resolvePackageDependencies && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify - - name: Carthage build + - name: "โš—๏ธ Run tests (swift)" run: | - carthage build --use-xcframeworks --no-skip-current + set -o pipefail && swift test -c release after_success: - needs: [test, test_carthage, test_linux] - name: Build demo projects + needs: [test_ios, test_macos] + name: "๐Ÿšš Build demo projects" if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - - name: Build demo projects + - name: "๐Ÿšš Build demo projects" run: | curl -X POST https://api.github.com/repos/surpher/pact-swift-examples/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -u ${{ secrets.PACT_SWIFT_TOKEN }} --data '{"event_type":"PactSwift - ${{ github.event.head_commit.message }}"}' diff --git a/.github/workflows/build_pr.yml b/.github/workflows/build_pr.yml index a7563230..d55b28dd 100644 --- a/.github/workflows/build_pr.yml +++ b/.github/workflows/build_pr.yml @@ -1,110 +1,86 @@ -name: Build PR +name: Build Pull Request on: pull_request: branches: - - 'main' - -env: - RUST_TARGET_PATH: pact-reference + - '!main' jobs: - test: - name: Run ${{ matrix.platform }} on ${{ matrix.host }} - runs-on: ${{ matrix.host }} - - strategy: - fail-fast: true - matrix: - host: [macos-11, macos-12] - platform: [ios, macos] - include: - - platform: ios - scheme: "PactSwift-iOS" - destination: "platform=iOS Simulator,name=iPhone 12 Pro" - - platform: macos - scheme: "PactSwift-macOS" - destination: "arch=x86_64" + test_macos: + name: "๐Ÿค– Test macOS" + runs-on: macos-13 env: - SCHEME: ${{ matrix.scheme }} - DESTINATION: ${{ matrix.destination }} + XCODE_VERSION: 14.3.1 + + concurrency: + group: test_macos13_darwin_$SCHEME_${{ github.ref }} + cancel-in-progress: true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 + + - name: "โš™๏ธ Use Xcode ${{ env.XCODE_VERSION }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ env.XCODE_VERSION }}.app - - name: Prepare Tools + - name: "๐Ÿงฐ Prepare tools" run: | Scripts/prepare_build_tools - - name: Run tests (Xcode) + - name: "๐Ÿงช xcodebuild clean test" run: | - set -o pipefail && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify + set -o pipefail && xcodebuild -resolvePackageDependencies | xcbeautify && xcodebuild clean test -project PactSwift.xcodeproj -scheme "PactSwift-macOS" -destination "arch=x86_64" | xcbeautify - - name: Run tests (CLI - Swift Package) + - name: "โš—๏ธ swift test" run: | - swift build - swift test -c release + set -o pipefail && swift test -c release - test_linux: - name: Run on Ubuntu - runs-on: ubuntu-latest - - strategy: - fail-fast: true - - steps: - - uses: fwal/setup-swift@v1 - - name: Get swift version - run: swift --version - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Protoc - uses: arduino/setup-protoc@v1 - - - name: "โ™ผ Cache rust binaries" - uses: actions/cache@v3 - with: - path: | - ${{ env.RUST_TARGET_PATH }} - key: build-${{ runner.os }}-rust-pactswift-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - build-${{ runner.os }}-rust-pactswift - build-${{ runner.os }}-rust- - - - name: "โš—๏ธ Build and Test" - run: | - Scripts/build_test_linux + test_ios: + name: "๐Ÿค– Test iOS" + runs-on: macos-13 + needs: [test_macos] - test_carthage: - name: Verify for Carthage - runs-on: macos-12 + env: + SCHEME: "PactSwift-iOS" + DESTINATION: "platform=iOS Simulator,name=iPhone 14 Pro" + XCODE_VERSION: 14.3.1 - strategy: - fail-fast: true + concurrency: + group: test_macos13_ios_$SCHEME_${{ github.ref }} + cancel-in-progress: true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 + + - name: "โš™๏ธ Use Xcode ${{ env.XCODE_VERSION }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ env.XCODE_VERSION }}.app - - name: Use Xcode 13.4.1 - run: sudo xcode-select -switch /Applications/Xcode_13.4.1.app + - name: "๐Ÿงฐ Prepare tools" + run: | + Scripts/prepare_build_tools + + - name: "โ™˜ Test for Carthage" + run: | + set -o pipefail && carthage build --no-skip-current --use-xcframeworks - - name: Carthage build + - name: "๐Ÿงช xcodebuild clean test" + run: | + set -o pipefail && xcodebuild -resolvePackageDependencies | xcbeautify && xcodebuild clean test -project PactSwift.xcodeproj -scheme "PactSwift-iOS" -destination "platform=iOS Simulator,name=iPhone 14 Pro" | xcbeautify + + - name: "โš—๏ธ swift test" run: | - carthage build --use-xcframeworks --no-skip-current + swift test -c release after_success: - needs: [test, test_carthage, test_linux] - name: Build demo projects + needs: [test_ios] + name: "๐Ÿšš Build demo projects" if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - - - name: Build demo projects + - name: "๐Ÿšš Build demo projects" run: | curl -X POST https://api.github.com/repos/surpher/pact-swift-examples/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -u ${{ secrets.PACT_SWIFT_TOKEN }} --data '{"event_type":"PactSwift - ${{ github.event.head_commit.message }}"}' + \ No newline at end of file diff --git a/Package.resolved b/Package.resolved index 1ef5dc8d..5ec94528 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,22 +1,13 @@ { "object": { "pins": [ - { - "package": "PactMockServer", - "repositoryURL": "https://github.com/surpher/PactMockServer.git", - "state": { - "branch": null, - "revision": "11fe519e6d1b0c513c717ba507e89ba401bdf8de", - "version": "0.1.2" - } - }, { "package": "PactSwiftMockServer", - "repositoryURL": "https://github.com/surpher/PactSwiftMockServer.git", + "repositoryURL": "https://github.com/surpher/PactSwiftServer.git", "state": { "branch": null, - "revision": "50c130088b9c7fe7f278beee86b3d161605a1f98", - "version": "0.4.1" + "revision": "12ecc92092ecd3640dcc2dcb98ce6b3d1f2d76f7", + "version": "0.4.7" } } ] diff --git a/Package.swift b/Package.swift index e19c8220..77705d08 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ let package = Package( name: "PactSwift", platforms: [ - .macOS(.v10_12), + .macOS(.v10_13), .iOS(.v12), .tvOS(.v12) ], @@ -19,7 +19,7 @@ let package = Package( ], dependencies: [ - .package(name: "PactSwiftMockServer", url: "https://github.com/surpher/PactSwiftServer.git", .exact("0.4.7")) + .package(url: "https://github.com/surpher/PactSwiftServer.git", .exact("0.4.7")) ], targets: [ @@ -28,8 +28,7 @@ let package = Package( .target( name: "PactSwift", dependencies: [ - .product(name: "PactSwiftMockServer", package: "PactSwiftMockServer", condition: .when(platforms: [.iOS, .macOS, .tvOS])), - .product(name: "PactSwiftMockServerLinux", package: "PactSwiftMockServer", condition: .when(platforms: [.linux])) + .product(name: "PactSwiftMockServer", package: "PactSwiftServer"), ], path: "./Sources" ), diff --git a/PactSwift.xcodeproj/project.pbxproj b/PactSwift.xcodeproj/project.pbxproj index f9623511..4a1d102b 100644 --- a/PactSwift.xcodeproj/project.pbxproj +++ b/PactSwift.xcodeproj/project.pbxproj @@ -125,6 +125,7 @@ AD92805626BE3361004FAA7E /* String+PactSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805426BE3361004FAA7E /* String+PactSwiftTests.swift */; }; AD92805826BE3705004FAA7E /* TransferProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805726BE3705004FAA7E /* TransferProtocolTests.swift */; }; AD92805926BE3705004FAA7E /* TransferProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805726BE3705004FAA7E /* TransferProtocolTests.swift */; }; + AD92E18F2A7DE6E7005C70E5 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */; }; AD957F3228A23A2300860AD1 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD957F3128A23A2300860AD1 /* Logger.swift */; }; AD957F3328A23A2300860AD1 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD957F3128A23A2300860AD1 /* Logger.swift */; }; AD9D7D8D26C8AD3400FE4137 /* ProviderStateGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9D7D8C26C8AD3400FE4137 /* ProviderStateGenerator.swift */; }; @@ -185,8 +186,6 @@ ADC3AA38247C8C4B0034446E /* InteractionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA36247C8C4B0034446E /* InteractionTests.swift */; }; ADC3AA3D247CBB550034446E /* IncludesLikeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA3C247CBB550034446E /* IncludesLikeTests.swift */; }; ADC3AA3E247CBB550034446E /* IncludesLikeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA3C247CBB550034446E /* IncludesLikeTests.swift */; }; - ADC50E272A7D2A7B004E1E03 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */; }; - ADC50E2B2A7D2D7E004E1E03 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */; }; ADD0315F2512193500C6099B /* ExampleGeneratorExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD0315E2512193500C6099B /* ExampleGeneratorExpressible.swift */; }; ADD031602512193500C6099B /* ExampleGeneratorExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD0315E2512193500C6099B /* ExampleGeneratorExpressible.swift */; }; ADD03164251219B700C6099B /* ExampleGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD03163251219B700C6099B /* ExampleGenerator.swift */; }; @@ -241,6 +240,7 @@ ADF959CB26C8F6EB00C35536 /* FromProviderStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959C926C8F6EB00C35536 /* FromProviderStateTests.swift */; }; ADF959CD26C8F98800C35536 /* ProviderStateGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959CC26C8F98800C35536 /* ProviderStateGeneratorTests.swift */; }; ADF959CE26C8F98800C35536 /* ProviderStateGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959CC26C8F98800C35536 /* ProviderStateGeneratorTests.swift */; }; + ADF994CE2A7DE1720011D974 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -410,6 +410,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + ADF994CE2A7DE1720011D974 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -418,7 +419,6 @@ buildActionMask = 2147483647; files = ( AD881808242C715B00BF510D /* PactSwift.framework in Frameworks */, - ADC50E272A7D2A7B004E1E03 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -426,6 +426,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + AD92E18F2A7DE6E7005C70E5 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -434,7 +435,6 @@ buildActionMask = 2147483647; files = ( AD8FC7C02463A06F00361854 /* PactSwift.framework in Frameworks */, - ADC50E2B2A7D2D7E004E1E03 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -791,6 +791,7 @@ ); name = PactSwift_iOS; packageProductDependencies = ( + ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */, ); productName = PACTSwift; productReference = AD8817FE242C715A00BF510D /* PactSwift.framework */; @@ -812,7 +813,6 @@ ); name = PactSwiftTests_iOS; packageProductDependencies = ( - ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */, ); productName = PACTSwiftTests; productReference = AD881807242C715B00BF510D /* PactSwiftTests_iOS.xctest */; @@ -836,6 +836,7 @@ ); name = PactSwift_macOS; packageProductDependencies = ( + AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */, ); productName = PactSwift_macOS; productReference = AD8FC7B72463A06F00361854 /* PactSwift.framework */; @@ -856,7 +857,6 @@ ); name = PactSwiftTests_macOS; packageProductDependencies = ( - ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */, ); productName = PactSwift_macOSTests; productReference = AD8FC7BF2463A06F00361854 /* PactSwiftTests_macOS.xctest */; @@ -898,7 +898,7 @@ ); mainGroup = AD8817F4242C715A00BF510D; packageReferences = ( - ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */, + ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */, ); productRefGroup = AD8817FF242C715A00BF510D /* Products */; projectDirPath = ""; @@ -1475,7 +1475,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */ = { + ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/surpher/PactSwiftServer.git"; requirement = { @@ -1486,14 +1486,14 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */ = { + AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */ = { isa = XCSwiftPackageProductDependency; - package = ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; + package = ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; productName = PactSwiftMockServer; }; - ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */ = { + ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */ = { isa = XCSwiftPackageProductDependency; - package = ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; + package = ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; productName = PactSwiftMockServer; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Scripts/build_rust_dependencies b/Scripts/build_rust_dependencies deleted file mode 100755 index f208cc32..00000000 --- a/Scripts/build_rust_dependencies +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash - -set -e pipefail - -PRODUCT_NAME="PactSwift" -WORKSPACE=${GITHUB_WORKSPACE:-$PWD} -LIBPACT_FFI_DIR="${WORKSPACE}/../pact-reference/rust/pact_ffi" -LIBPACT_PRODUCT_DIR="${WORKSPACE}/../pact-reference/rust/target/debug" -CI=${CI:-"false"} -PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" - -####################### -# Pre-requisite # -####################### - -if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] -then - echo "๐Ÿšจ Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." - echo "โš ๏ธ You are runing it in $PWD" - exit 1 -fi - -####################### -# If CI # -####################### - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Verifying project and dependencies' folder setup..." - -if [[ "$CI" == true ]]; then - echo "โ„น๏ธ Adding submodule ${PACT_FOUNDATION_REPO}" - if [ ! -d "$PWD/pact-reference"]; then - git submodule add $PACT_FOUNDATION_REPO - fi - git submodule update --init - cd pact-reference/rust/pact_ffi -elif [ ! -d "$PWD/../pact-reference" ]; then - echo "๐Ÿšจ Missing pact-foundation/pact-reference repo." - echo "โš ๏ธ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." - exit 1 -else - echo "๐Ÿ‘ Project setup seems to be in order." - echo "โ„น๏ธ Changing location to ${LIBPACT_FFI_DIR}" - cd $LIBPACT_FFI_DIR -fi - -####################### -# Setup # -####################### - -# Validate dependencies - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Checking if Rust is installed..." -if which cargo >/dev/null; then - echo "๐Ÿ‘ cargo installed" -elif command -v ~/.cargo/bin/cargo &> /dev/null; then - echo "๐Ÿ‘ cargo installed in ~/.cargo/bin/" -else - echo "๐Ÿšจ Rust/Cargo not installed" - echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" - exit 1 -fi - -############################################## -# Build libpact_ffi libraries # -############################################## - -# Using debug build flag (or not providing it), otherwise libpact_ffi.so must be moved into /usr/local/lib/ -echo "๐Ÿ— Building libpact_ffi for current platform (debug build)" -cargo build -echo "โœ… libpact_ffi built" - -echo "โ„น๏ธ Setting LD_LIBRARY_PATH to include $LIBPACT_PRODUCT_DIR" -if [[ "$CI" == true ]]; then - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${WORKSPACE}/pact-reference/rust/target/debug" -else - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LIBPACT_PRODUCT_DIR}" -fi - -####################### -# Cleanup # -####################### - -echo "โ„น๏ธ Changing directory back to ${WORKSPACE}" -cd ${WORKSPACE} - -############################################################################################################## -# Run Swift buld and test # -# https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md#requiring-system-libraries # -############################################################################################################## - -echo "โ„น๏ธ Running swift build:" -swift build -Xlinker -L$LIBPACT_PRODUCT_DIR - -echo "โ„น๏ธ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" - -if [[ "$CI" == true ]]; then - BIN_PATH="${WORKSPACE}/pact-reference/rust/target/debug" - swift test -Xlinker -L$BIN_PATH -else - swift test -Xlinker -L$LIBPACT_PRODUCT_DIR -fi diff --git a/Scripts/build_test_linux b/Scripts/build_test_linux deleted file mode 100755 index 97560652..00000000 --- a/Scripts/build_test_linux +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# ### Pre-requisites: -# -# `pact-reference` repo and `PactSwift` repo are on the same folder level -# -# ### Usage: -# ./Support/build_rust_dependencies -# -# In order to minimise the built binary size update $LIBPACT_FFI_DI/Cargo.toml and append the following: -# -# [lib] -# crate-type = ["staticlib"] -# -# [profile.release] -# opt-level = 'z' -# lto = true -# panic = 'abort' -# -####################### - -PRODUCT_NAME="PactSwift" -WORKSPACE=${GITHUB_WORKSPACE:-$PWD} -LIBPACT_FFI_DIR="${WORKSPACE}/pact-reference/rust/pact_ffi" -LIBPACT_PRODUCT_DIR="${WORKSPACE}/pact-reference/rust/target/debug" -CI=${CI:-"false"} -PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" - -####################### -# Pre-requisite # -####################### - -if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] -then - echo "๐Ÿšจ Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." - echo "โš ๏ธ You are runing it in $PWD" - exit 1 -fi - -####################### -# If CI # -####################### - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Verifying project and dependencies' folder setup..." - -if [[ "$CI" == true ]]; then - echo "โ„น๏ธ Adding submodule ${PACT_FOUNDATION_REPO}" - if [ ! -d "$PWD/pact-reference" ]; then - git submodule add $PACT_FOUNDATION_REPO - git submodule update --init - - echo "โ„น๏ธ Changing location to ${LIBPACT_FFI_DIR}" - cd $LIBPACT_FFI_DIR - git fetch --all --tags - git checkout tags/libpact_ffi-v0.3.11 - fi - - export LD_LIBRARY_PATH="/usr/local/lib" - -elif [ ! -d "$PWD/../pact-reference" ]; then - # TODO: fix this for running locally - echo "๐Ÿšจ Missing pact-foundation/pact-reference repo." - echo "โš ๏ธ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." - exit 1 -else - echo "๐Ÿ‘ Project setup seems to be in order." -fi - -echo "โ„น๏ธ Changing location to ${LIBPACT_FFI_DIR}" -cd $LIBPACT_FFI_DIR - -####################### -# Setup # -####################### - -# Validate dependencies - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Checking if Rust is installed..." -if which cargo >/dev/null; then - echo "๐Ÿ‘ cargo installed" -elif command -v ~/.cargo/bin/cargo &> /dev/null; then - echo "๐Ÿ‘ cargo installed in ~/.cargo/bin/" -else - echo "๐Ÿšจ Rust/Cargo not installed" - echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" - exit 1 -fi - -############################################## -# Build libpact_ffi libraries # -############################################## - -# Using debug build flag (or not providing it), otherwise libpact_ffi.so must be moved into /usr/local/lib/ -echo "๐Ÿ— Building libpact_ffi for current platform (debug build)" -cargo build -echo "โœ… libpact_ffi built" - -echo "โ„น๏ธ Setting LD_LIBRARY_PATH to include $LIBPACT_PRODUCT_DIR" -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBPACT_PRODUCT_DIR - -####################### -# Cleanup # -####################### - -echo "โ„น๏ธ Changing directory back to ${WORKSPACE}" -cd ${WORKSPACE} - -############################################################################################################## -# Run Swift buld and test # -# https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md#requiring-system-libraries # -############################################################################################################## - -echo "โ„น๏ธ Running swift build:" -swift build -Xlinker -L$LIBPACT_PRODUCT_DIR - -echo "โ„น๏ธ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" -swift test -Xlinker -L$LIBPACT_PRODUCT_DIR \ No newline at end of file diff --git a/Scripts/check_build_tools b/Scripts/check_build_tools index 1c605c49..3e05dc37 100755 --- a/Scripts/check_build_tools +++ b/Scripts/check_build_tools @@ -11,13 +11,6 @@ else echo "warning: SwiftLint not installed, use 'brew install swiftlint' to install it." fi -if which carthage >/dev/null; then - echo "๐Ÿ‘ carthage installed" -else - echo "โš ๏ธ carthage" - echo "warning: carthage not installed, use 'brew install carthage' to install it." -fi - # Checking for xcbeautify if which xcbeautify >/dev/null; then echo "๐Ÿ‘ xcbeautify installed" diff --git a/Scripts/prepare_build_tools b/Scripts/prepare_build_tools index 68ab1ea2..38b8c310 100755 --- a/Scripts/prepare_build_tools +++ b/Scripts/prepare_build_tools @@ -1,6 +1,5 @@ #!/usr/bin/env bash -brew install rust brew tap thii/xcbeautify https://github.com/thii/xcbeautify.git brew install xcbeautify diff --git a/Scripts/run_tests b/Scripts/run_tests index bdbc8ca7..ee84865c 100755 --- a/Scripts/run_tests +++ b/Scripts/run_tests @@ -4,7 +4,7 @@ set -eu set -o pipefail # Overridable Environment -SIMULATOR_NAME=${SIMULATOR_NAME:-'iPhone 12 Pro'} +SIMULATOR_NAME=${SIMULATOR_NAME:-'iPhone 14 Pro'} SCRIPTS_DIR="${BASH_SOURCE[0]%/*}" # Determine architecture of current machine @@ -28,10 +28,10 @@ echo "โ„น๏ธ Resolving package dependencies" xcodebuild -resolvePackageDependencies echo "๐Ÿ— Building" -swift build +swift build | xcbeautify echo "๐Ÿค– Running tests" -swift test +swift test | xcbeautify # Run iOS tests echo "๐Ÿ“ฑ Running iOS tests" diff --git a/Sources/ExampleGenerators/DateTime.swift b/Sources/ExampleGenerators/DateTime.swift index 3ee2e641..2be3304b 100644 --- a/Sources/ExampleGenerators/DateTime.swift +++ b/Sources/ExampleGenerators/DateTime.swift @@ -34,7 +34,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorDateTime) public class ObjcDateTime: NSObject, ObjcGenerator { @@ -52,4 +51,3 @@ public class ObjcDateTime: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/DateTimeExpression.swift b/Sources/ExampleGenerators/DateTimeExpression.swift index ef6195e2..af15c7a3 100644 --- a/Sources/ExampleGenerators/DateTimeExpression.swift +++ b/Sources/ExampleGenerators/DateTimeExpression.swift @@ -41,7 +41,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorDateTimeExpression) public class OjbcDateTimeExpression: NSObject, ObjcGenerator { @@ -61,4 +60,3 @@ public class OjbcDateTimeExpression: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomBool.swift b/Sources/ExampleGenerators/RandomBool.swift index 241917bd..0ea5d94c 100644 --- a/Sources/ExampleGenerators/RandomBool.swift +++ b/Sources/ExampleGenerators/RandomBool.swift @@ -33,7 +33,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomBool) public class ObjcRandomBool: NSObject, ObjcGenerator { @@ -45,4 +44,3 @@ public class ObjcRandomBool: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomDate.swift b/Sources/ExampleGenerators/RandomDate.swift index 047b53d3..a83094de 100644 --- a/Sources/ExampleGenerators/RandomDate.swift +++ b/Sources/ExampleGenerators/RandomDate.swift @@ -45,7 +45,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomDate) public class ObjcRandomDate: NSObject, ObjcGenerator { @@ -62,4 +61,3 @@ public class ObjcRandomDate: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomDateTime.swift b/Sources/ExampleGenerators/RandomDateTime.swift index 8456bbe1..cba4a849 100644 --- a/Sources/ExampleGenerators/RandomDateTime.swift +++ b/Sources/ExampleGenerators/RandomDateTime.swift @@ -45,7 +45,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomDateTime) public class ObjcRandomDateTime: NSObject, ObjcGenerator { @@ -62,4 +61,3 @@ public class ObjcRandomDateTime: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomDecimal.swift b/Sources/ExampleGenerators/RandomDecimal.swift index 14df8343..a591def7 100644 --- a/Sources/ExampleGenerators/RandomDecimal.swift +++ b/Sources/ExampleGenerators/RandomDecimal.swift @@ -58,7 +58,6 @@ private enum NumberHelper { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomDecimal) public class ObjcRandomDecimal: NSObject, ObjcGenerator { @@ -77,4 +76,3 @@ public class ObjcRandomDecimal: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomHexadecimal.swift b/Sources/ExampleGenerators/RandomHexadecimal.swift index 33e13950..b2720e4d 100644 --- a/Sources/ExampleGenerators/RandomHexadecimal.swift +++ b/Sources/ExampleGenerators/RandomHexadecimal.swift @@ -45,7 +45,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomHexadecimal) public class ObjcRandomHexadecimal: NSObject, ObjcGenerator { @@ -64,4 +63,3 @@ public class ObjcRandomHexadecimal: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomInt.swift b/Sources/ExampleGenerators/RandomInt.swift index 2d2341c4..cd14d7b4 100644 --- a/Sources/ExampleGenerators/RandomInt.swift +++ b/Sources/ExampleGenerators/RandomInt.swift @@ -46,7 +46,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomInt) public class ObjcRandomInt: NSObject, ObjcGenerator { @@ -66,4 +65,3 @@ public class ObjcRandomInt: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomString.swift b/Sources/ExampleGenerators/RandomString.swift index fc5af850..73b00ebb 100644 --- a/Sources/ExampleGenerators/RandomString.swift +++ b/Sources/ExampleGenerators/RandomString.swift @@ -17,9 +17,7 @@ import Foundation -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer @@ -74,7 +72,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomString) public class ObjcRandomString: NSObject, ObjcGenerator { @@ -107,4 +104,3 @@ public class ObjcRandomString: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomTime.swift b/Sources/ExampleGenerators/RandomTime.swift index 3ccf4dbd..2fc00c57 100644 --- a/Sources/ExampleGenerators/RandomTime.swift +++ b/Sources/ExampleGenerators/RandomTime.swift @@ -45,7 +45,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomTime) public class ObjcRandomTime: NSObject, ObjcGenerator { @@ -62,4 +61,3 @@ public class ObjcRandomTime: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/ExampleGenerators/RandomUUID.swift b/Sources/ExampleGenerators/RandomUUID.swift index 04919adc..930481ce 100644 --- a/Sources/ExampleGenerators/RandomUUID.swift +++ b/Sources/ExampleGenerators/RandomUUID.swift @@ -69,7 +69,6 @@ public extension ExampleGenerator { // MARK: - Objective-C -#if !os(Linux) @objc(PFGeneratorRandomUUID) public class ObjcRandomUUID: NSObject, ObjcGenerator { @@ -122,4 +121,3 @@ public class ObjcRandomUUID: NSObject, ObjcGenerator { } } -#endif diff --git a/Sources/Extensions/MockServer+Async.swift b/Sources/Extensions/MockServer+Async.swift index 9c649428..336e8a2a 100644 --- a/Sources/Extensions/MockServer+Async.swift +++ b/Sources/Extensions/MockServer+Async.swift @@ -15,7 +15,7 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) +#if canImport(_Concurrency) && compiler(>=5.7) import Foundation @_implementationOnly import PactSwiftMockServer diff --git a/Sources/Extensions/Task+Timeout.swift b/Sources/Extensions/Task+Timeout.swift index e12546db..492fc99b 100644 --- a/Sources/Extensions/Task+Timeout.swift +++ b/Sources/Extensions/Task+Timeout.swift @@ -15,7 +15,7 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) +#if canImport(_Concurrency) && compiler(>=5.7) import Foundation diff --git a/Sources/Matchers/DecimalLike.swift b/Sources/Matchers/DecimalLike.swift index e42c4e44..e4f5c728 100644 --- a/Sources/Matchers/DecimalLike.swift +++ b/Sources/Matchers/DecimalLike.swift @@ -51,7 +51,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) /// Mathes a `Decimal` value. /// /// Use this matcher when you expect the type being returned by the API provider is a `Decimal`. @@ -79,4 +78,3 @@ public class ObjcDecimalLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/EachKeyLike.swift b/Sources/Matchers/EachKeyLike.swift index 207ef4c6..00b8c40e 100644 --- a/Sources/Matchers/EachKeyLike.swift +++ b/Sources/Matchers/EachKeyLike.swift @@ -155,7 +155,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherEachKeyLike) public class ObjcEachKeyLike: NSObject, ObjcMatcher { @@ -178,4 +177,3 @@ public class ObjcEachKeyLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/EachLike.swift b/Sources/Matchers/EachLike.swift index f9616f90..7bf49d3e 100644 --- a/Sources/Matchers/EachLike.swift +++ b/Sources/Matchers/EachLike.swift @@ -128,7 +128,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherEachLike) public class ObjcEachLike: NSObject, ObjcMatcher { @@ -164,4 +163,3 @@ public class ObjcEachLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/EqualTo.swift b/Sources/Matchers/EqualTo.swift index 33456e93..92ba0ed1 100644 --- a/Sources/Matchers/EqualTo.swift +++ b/Sources/Matchers/EqualTo.swift @@ -52,7 +52,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherEqualTo) public class ObjcEqualTo: NSObject, ObjcMatcher { @@ -68,4 +67,3 @@ public class ObjcEqualTo: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/FromProviderState.swift b/Sources/Matchers/FromProviderState.swift index 9c2d8682..589028ad 100644 --- a/Sources/Matchers/FromProviderState.swift +++ b/Sources/Matchers/FromProviderState.swift @@ -60,7 +60,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherFromProviderState) public class ObjcFromProviderState: NSObject, ObjcMatcher { @@ -133,4 +132,3 @@ public class ObjcFromProviderState: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/IncludesLike.swift b/Sources/Matchers/IncludesLike.swift index ca4ebfdd..09fcdd6a 100644 --- a/Sources/Matchers/IncludesLike.swift +++ b/Sources/Matchers/IncludesLike.swift @@ -84,7 +84,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherIncludesLike) public class ObjcIncludesLike: NSObject, ObjcMatcher { @@ -115,4 +114,3 @@ public class ObjcIncludesLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/IntegerLike.swift b/Sources/Matchers/IntegerLike.swift index 41b073ab..64334d23 100644 --- a/Sources/Matchers/IntegerLike.swift +++ b/Sources/Matchers/IntegerLike.swift @@ -45,7 +45,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherIntegerLike) public class ObjcIntegerLike: NSObject, ObjcMatcher { @@ -62,4 +61,3 @@ public class ObjcIntegerLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/MatchNull.swift b/Sources/Matchers/MatchNull.swift index 97f8527f..0dedac6e 100644 --- a/Sources/Matchers/MatchNull.swift +++ b/Sources/Matchers/MatchNull.swift @@ -37,7 +37,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherNull) public class ObjcMatchNull: NSObject, ObjcMatcher { @@ -49,4 +48,3 @@ public class ObjcMatchNull: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/OneOf.swift b/Sources/Matchers/OneOf.swift index 7cf258ab..7f54d3cc 100644 --- a/Sources/Matchers/OneOf.swift +++ b/Sources/Matchers/OneOf.swift @@ -73,7 +73,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherOneOf) public class ObjcOneOf: NSObject, ObjcMatcher { @@ -92,4 +91,3 @@ public class ObjcOneOf: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/RegexLike.swift b/Sources/Matchers/RegexLike.swift index 85899331..ef2e357a 100644 --- a/Sources/Matchers/RegexLike.swift +++ b/Sources/Matchers/RegexLike.swift @@ -77,7 +77,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherRegexLike) public class ObjcRegexLike: NSObject, ObjcMatcher { @@ -111,4 +110,3 @@ public class ObjcRegexLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/Matchers/SomethingLike.swift b/Sources/Matchers/SomethingLike.swift index 5394c3fd..1a5fc8f9 100644 --- a/Sources/Matchers/SomethingLike.swift +++ b/Sources/Matchers/SomethingLike.swift @@ -51,7 +51,6 @@ public extension Matcher { // MARK: - Objective-C -#if !os(Linux) @objc(PFMatcherSomethingLike) public class ObjcSomethingLike: NSObject, ObjcMatcher { @@ -68,4 +67,3 @@ public class ObjcSomethingLike: NSObject, ObjcMatcher { } } -#endif diff --git a/Sources/MockService.swift b/Sources/MockService.swift index 5f0d6a73..e76d5971 100644 --- a/Sources/MockService.swift +++ b/Sources/MockService.swift @@ -18,9 +18,7 @@ import Foundation import XCTest -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer @@ -42,11 +40,7 @@ open class MockService { private let pactsDirectory: URL? private let merge: Bool - #if os(Linux) - private var transferProtocolScheme: PactSwiftMockServerLinux.TransferProtocol - #else private var transferProtocolScheme: PactSwiftMockServer.TransferProtocol - #endif // MARK: - Initializers @@ -158,7 +152,7 @@ open class MockService { } } - #if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) + #if canImport(_Concurrency) && compiler(>=5.7) /// Runs the Pact test against the code making the API request /// /// - Parameters: @@ -245,7 +239,7 @@ extension MockService { } } - #if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) + #if canImport(_Concurrency) && compiler(>=5.7) /// Writes a Pact contract file in JSON format /// /// By default Pact contracts are written to `/tmp/pacts` folder. @@ -333,7 +327,7 @@ private extension MockService { } } - #if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) + #if canImport(_Concurrency) && compiler(>=5.7) @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) func setupPactInteraction(timeout: TimeInterval, file: FileString?, line: UInt?, mockServer: MockServer, testFunction: @escaping @Sendable (String) async throws -> Void) async throws { Logger.log(message: "Setting up pact test", data: pact.data) @@ -364,10 +358,10 @@ private extension MockService { _ = try await task.value // If the comsumer (in testFunction:) made the promised request to Mock Server, go and finalize the test. - // Only finalize when running in simulator, maOS or Linux. Running on a physical iOS device makes little sense due to + // Only finalize when running in simulator or macOS. Running on a physical iOS device makes little sense due to // writing a pact file to device's disk. `libpact_ffi` does the actual file writing it writes it onto the // disk of the device it is being run on. - #if targetEnvironment(simulator) || os(macOS) || os(Linux) + #if targetEnvironment(simulator) || os(macOS) let message = try await finalize(file: file, line: line) Logger.log(message: message, data: self.pact.data) #else @@ -387,10 +381,10 @@ private extension MockService { switch $0 { case .success: // If the comsumer (in testFunction:) made the promised request to Mock Server, go and finalize the test. - // Only finalize when running in simulator, maOS or Linux. Running on a physical iOS device makes little sense due to + // Only finalize when running in simulator or macOS. Running on a physical iOS device makes little sense due to // writing a pact file to device's disk. `libpact_ffi` does the actual file writing it writes it onto the // disk of the device it is being run on. - #if targetEnvironment(simulator) || os(macOS) || os(Linux) + #if targetEnvironment(simulator) || os(macOS) finalize(file: file, line: line) { switch $0 { case .success(let message): diff --git a/Sources/Model/Interaction.swift b/Sources/Model/Interaction.swift index cac95ff2..7bfaf6a3 100644 --- a/Sources/Model/Interaction.swift +++ b/Sources/Model/Interaction.swift @@ -17,18 +17,6 @@ import Foundation -#if os(Linux) -/// Defines the interaction between a consumer and a provider -public class Interaction: NSObject { - var interactionDescription: String? - var providerState: String? - var providerStates: [ProviderState]? - var request: Request? - var response: Response? - - internal var encodingErrors = [EncodingError]() -} -#else /// Defines the interaction between a consumer and a provider @objc public class Interaction: NSObject { var interactionDescription: String? @@ -39,7 +27,6 @@ public class Interaction: NSObject { internal var encodingErrors = [EncodingError]() } -#endif extension Interaction: Encodable { @@ -57,17 +44,10 @@ extension Interaction: Encodable { extension Interaction { - #if os(Linux) - convenience init(description: String) { - self.init() - self.interactionDescription = description - } - #else @objc convenience init(description: String) { self.init() self.interactionDescription = description } - #endif convenience init(description: String, providerState: String, request: Request? = nil, response: Response? = nil) { self.init() @@ -239,7 +219,6 @@ extension Interaction { return self } - #if !os(Linux) // MARK: - Objective-C - /// Defines the description of the interaction @@ -323,6 +302,5 @@ extension Interaction { willRespondWith(status: status, headers: headers, body: body) return self } - #endif } diff --git a/Sources/Model/PactHTTPMethod.swift b/Sources/Model/PactHTTPMethod.swift index 4dc96b92..52f50e4d 100644 --- a/Sources/Model/PactHTTPMethod.swift +++ b/Sources/Model/PactHTTPMethod.swift @@ -17,20 +17,6 @@ import Foundation -#if os(Linux) -/// The HTTP method expected in the interaction -public enum PactHTTPMethod { - case GET - case HEAD - case POST - case PUT - case PATCH - case DELETE - case TRACE - case CONNECT - case OPTIONS -} -#else /// The HTTP method expected in the interaction @objc public enum PactHTTPMethod: Int { case GET @@ -43,7 +29,6 @@ public enum PactHTTPMethod { case CONNECT case OPTIONS } -#endif extension PactHTTPMethod { diff --git a/Sources/Model/ProviderState.swift b/Sources/Model/ProviderState.swift index 71ce6f09..fe5c156a 100644 --- a/Sources/Model/ProviderState.swift +++ b/Sources/Model/ProviderState.swift @@ -44,7 +44,6 @@ extension ProviderState: Equatable { } // MARK: - Objective-C -#if !os(Linux) /*! @brief Object describing expected provider state for an interaction @@ -67,4 +66,3 @@ public final class ObjCProviderState: NSObject { } } -#endif diff --git a/Sources/Model/TransferProtocol.swift b/Sources/Model/TransferProtocol.swift index 78fdcb86..5eab8372 100644 --- a/Sources/Model/TransferProtocol.swift +++ b/Sources/Model/TransferProtocol.swift @@ -17,45 +17,12 @@ import Foundation -#if os(Linux) - -import PactSwiftMockServerLinux - -/// Defines the transfer protocol on which `MockService` runs. -public enum TransferProtocol { - case standard - case secure - - var bridge: PactSwiftMockServerLinux.TransferProtocol { - switch self { - case .standard: return .standard - case .secure: return .secure - } - } -} - -#elseif compiler(>=5.5) +#if compiler(>=5.5) // This is ridiculous! This works when building on macOS 11+. - @_implementationOnly import PactSwiftMockServer - -/// Defines the transfer protocol on which `MockService` runs. -@objc public enum TransferProtocol: Int { - case standard - case secure - - var bridge: PactSwiftMockServer.TransferProtocol { - switch self { - case .standard: return .standard - case .secure: return .secure - } - } -} - #else -// Still ridiculous! This works when building on macOS pre 11. - import PactSwiftMockServer +#endif /// Defines the transfer protocol on which `MockService` runs. @objc public enum TransferProtocol: Int { @@ -70,8 +37,6 @@ import PactSwiftMockServer } } -#endif - extension TransferProtocol { /// HTTP Transfer protocol diff --git a/Sources/PFMockService.swift b/Sources/PFMockService.swift index 7bfed243..4835b3bc 100644 --- a/Sources/PFMockService.swift +++ b/Sources/PFMockService.swift @@ -15,14 +15,10 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if !os(Linux) - import Foundation import XCTest -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer @@ -115,5 +111,3 @@ import PactSwiftMockServer } } - -#endif diff --git a/Sources/ProviderVerifier.swift b/Sources/ProviderVerifier.swift index fa2a3bea..a388e773 100644 --- a/Sources/ProviderVerifier.swift +++ b/Sources/ProviderVerifier.swift @@ -18,9 +18,7 @@ import Foundation import XCTest -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer diff --git a/Sources/Toolbox/Logger.swift b/Sources/Toolbox/Logger.swift index 994a85b5..4018ef32 100644 --- a/Sources/Toolbox/Logger.swift +++ b/Sources/Toolbox/Logger.swift @@ -16,9 +16,7 @@ // import Foundation -#if !os(Linux) import os.log -#endif enum Logger { @@ -38,17 +36,12 @@ enum Logger { let stringData = data.flatMap { String(data: $0, encoding: .utf8) } ?? "" if #available(iOS 10, OSX 10.14, *) { - #if !os(Linux) os_log( "PactSwift: %{private}s", log: .default, type: .default, "\(message): \(stringData)" ) - #else - print(message: "PactSwift: \(message)\n\(stringData)") - #endif - } else { print(message: "PactSwift: \(message)\n\(stringData)") } diff --git a/Tests/ExampleGenerators/ObjCExampleGeneratorTests.swift b/Tests/ExampleGenerators/ObjCExampleGeneratorTests.swift index ed64b715..63b5a84d 100644 --- a/Tests/ExampleGenerators/ObjCExampleGeneratorTests.swift +++ b/Tests/ExampleGenerators/ObjCExampleGeneratorTests.swift @@ -15,8 +15,6 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if !os(Linux) - import XCTest @testable import PactSwift @@ -92,5 +90,3 @@ class ObjCExampleGeneratorTests: XCTestCase { } } - -#endif diff --git a/Tests/Matchers/ObjCMatcherTests.swift b/Tests/Matchers/ObjCMatcherTests.swift index 14efd0c7..9bc9e6fa 100644 --- a/Tests/Matchers/ObjCMatcherTests.swift +++ b/Tests/Matchers/ObjCMatcherTests.swift @@ -15,8 +15,6 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if !os(Linux) - import XCTest @testable import PactSwift @@ -170,5 +168,3 @@ class ObjCMatcherTests: XCTestCase { } } - -#endif diff --git a/Tests/Model/MetadataTests.swift b/Tests/Model/MetadataTests.swift index 9963bb00..d14ca7b6 100644 --- a/Tests/Model/MetadataTests.swift +++ b/Tests/Model/MetadataTests.swift @@ -28,11 +28,7 @@ class MetadataTests: XCTestCase { #if !SWIFT_PACKAGE func testMetadata_SetsPactSwiftVersion() throws { guard let expectedResult = bundleVersion() else { - #if os(Linux) - print("This test is irrelevant on Linux platforms") - #else XCTFail("Expected version number") - #endif return } XCTAssertEqual(try XCTUnwrap(Metadata().pactSwift.version), expectedResult) diff --git a/Tests/Model/TransferProtocolTests.swift b/Tests/Model/TransferProtocolTests.swift index 96a28539..f9399b2f 100644 --- a/Tests/Model/TransferProtocolTests.swift +++ b/Tests/Model/TransferProtocolTests.swift @@ -19,9 +19,7 @@ import XCTest @testable import PactSwift -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer @@ -34,16 +32,9 @@ class TransferProtocolTests: XCTestCase { XCTAssertEqual(TransferProtocol.secure.protocol, "https") } - #if os(Linux) - func testTransferProtocolBridge() { - XCTAssertEqual(TransferProtocol.standard.bridge, PactSwiftMockServerLinux.TransferProtocol.standard) - XCTAssertEqual(TransferProtocol.secure.bridge, PactSwiftMockServerLinux.TransferProtocol.secure) - } - #else func testTransferProtocolBridge() { XCTAssertEqual(TransferProtocol.standard.bridge, PactSwiftMockServer.TransferProtocol.standard) XCTAssertEqual(TransferProtocol.secure.bridge, PactSwiftMockServer.TransferProtocol.secure) } - #endif } diff --git a/Tests/Services/AsyncMockServiceTests.swift b/Tests/Services/AsyncMockServiceTests.swift index ceeef771..3f6ed3d4 100644 --- a/Tests/Services/AsyncMockServiceTests.swift +++ b/Tests/Services/AsyncMockServiceTests.swift @@ -20,8 +20,7 @@ import XCTest import Foundation -// FoundationNetworking for Linux does not seem to support the async `URLSession.data(from:)` methods. -#if canImport(_Concurrency) && compiler(>=5.7) && !os(Linux) +#if canImport(_Concurrency) && compiler(>=5.7) final class MockServiceAsyncTests: XCTestCase { var mockService: MockService! diff --git a/Tests/Services/MockServiceTests.swift b/Tests/Services/MockServiceTests.swift index 9910ebb7..9defecc4 100644 --- a/Tests/Services/MockServiceTests.swift +++ b/Tests/Services/MockServiceTests.swift @@ -19,10 +19,6 @@ import XCTest @testable import PactSwift -#if os(Linux) -import FoundationNetworking -#endif - class MockServiceTests: XCTestCase { var mockService: MockService! @@ -109,7 +105,6 @@ class MockServiceTests: XCTestCase { waitForExpectations(timeout: 1) } - #if !os(Linux) // Linux does not seem to support this and URLSessionDelegate func testMockService_SuccessfulGETRequest_OverSSL() { mockService = MockService( @@ -157,7 +152,6 @@ class MockServiceTests: XCTestCase { waitForExpectations(timeout: 1) } - #endif func testMockService_Fails_WhenRequestMissing() { mockService @@ -991,7 +985,6 @@ private extension MockServiceTests { // MARK: - URLSessionDelegate -#if !os(Linux) extension MockServiceTests: URLSessionDelegate { func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { @@ -1010,7 +1003,6 @@ extension MockServiceTests: URLSessionDelegate { } } -#endif // MARK: - FileManager diff --git a/Tests/Services/MockServiceWithDirectoryPathTests.swift b/Tests/Services/MockServiceWithDirectoryPathTests.swift index 2308deb9..a3e4e6f7 100644 --- a/Tests/Services/MockServiceWithDirectoryPathTests.swift +++ b/Tests/Services/MockServiceWithDirectoryPathTests.swift @@ -19,20 +19,12 @@ import XCTest @testable import PactSwift -#if os(Linux) -import FoundationNetworking -#endif - final class MockServiceWithDirectoryPathTests: XCTestCase { static private let expectedTargetDirectory = URL(fileURLWithPath: "/tmp/pacts/custom/path", isDirectory: true) static private var mockService: MockService! - #if os(Linux) - let session = URLSession.shared - #else let session = URLSession(configuration: .ephemeral) - #endif override class func setUp() { mockService = MockService(consumer: "custom-dir-consumer", provider: "provider", writePactTo: MockServiceWithDirectoryPathTests.expectedTargetDirectory) diff --git a/Tests/Services/PFMockServiceTests.swift b/Tests/Services/PFMockServiceTests.swift index 4db6c039..1448350e 100644 --- a/Tests/Services/PFMockServiceTests.swift +++ b/Tests/Services/PFMockServiceTests.swift @@ -15,8 +15,6 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if !os(Linux) - import XCTest @testable import PactSwift @@ -161,5 +159,3 @@ class PFMockServiceTests: XCTestCase { } } - -#endif diff --git a/Tests/Services/PactContractTests.swift b/Tests/Services/PactContractTests.swift index 3e03a31b..b5723f35 100644 --- a/Tests/Services/PactContractTests.swift +++ b/Tests/Services/PactContractTests.swift @@ -19,10 +19,6 @@ import XCTest @testable import PactSwift -#if os(Linux) -import FoundationNetworking -#endif - private class MockServiceWrapper { static let shared = MockServiceWrapper() @@ -42,11 +38,7 @@ class PactContractTests: XCTestCase { var mockService = MockServiceWrapper.shared.mockService - #if os(Linux) - let session = URLSession.shared - #else let session = URLSession(configuration: .ephemeral) - #endif static var errorCapture = MockServiceWrapper.shared.errorCapture static let pactContractFileName = "\(MockServiceWrapper.shared.consumer)-\(MockServiceWrapper.shared.provider).json" @@ -61,171 +53,171 @@ class PactContractTests: XCTestCase { } override class func tearDown() { - do { - let fileContents = try XCTUnwrap(FileManager.default.contents(atPath: PactFileManager.pactDirectoryPath + "/" + self.pactContractFileName)) - let jsonObject = try JSONSerialization.jsonObject(with: fileContents, options: []) as! [String: Any] - - // Validate the final Pact contract file contains values that were specified in tests' expectations - - // MARK: - Validate Interactions - - let interactions = try XCTUnwrap(jsonObject["interactions"] as? [Any]) - let numOfExpectedInteractions = 11 - - assert( - interactions.count == numOfExpectedInteractions, - "Expected \(numOfExpectedInteractions) interactions in Pact contract but got \(interactions.count)!" - ) - - // MARK: - Validate Matchers for Interactions - - // Validate interaction "bug example" - let bugExampleInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "bug example") - // print("\nMATCHERS:\n\(matchersOne)") - let expectedMatchersOne = [ - "$.array_of_objects", - "$.array_of_objects[*].key_for_explicit_array[0]", - "$.array_of_objects[*].key_for_explicit_array[1]", - "$.array_of_objects[*].key_for_explicit_array[2]", - "$.array_of_objects[*].key_for_explicit_array[3]", - "$.array_of_objects[*].key_for_explicit_array[4]", - "$.array_of_objects[*].key_for_matcher_array", - "$.array_of_objects[*].key_for_matcher_array[*]", - "$.array_of_objects[*].key_int", - "$.array_of_objects[*].key_string", - "$.array_of_strings", - "$.array_of_strings[*]", - "$.includes_like", - ] - assert( - expectedMatchersOne.allSatisfy { expectedKey -> Bool in - bugExampleInteraction.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } - }, - "Not all expected generators found in Pact contract file" - ) - - // Validate interaction "a request for roles with sub-roles" - let arrayOnRootInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "a request for roles with sub-roles") - let expectedNodesForArrayOnRoot = [ - "$[*].id" - ] - assert( - expectedNodesForArrayOnRoot.allSatisfy { expectedKey -> Bool in - arrayOnRootInteraction.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } - }, - "Not all expected generators found in Pact contract file" - ) - - // Validate interaction "Request for animals with children" - let animalsWithChildrenInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "a request for animals with children") - let expectedNodesForAnimalsWithChildren = [ - "$.animals", - "$.animals[*].children", - "$.animals[*].children[*]", - ] - assert( - expectedNodesForAnimalsWithChildren.allSatisfy { expectedKey -> Bool in - animalsWithChildrenInteraction.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } + do { + let fileContents = try XCTUnwrap(FileManager.default.contents(atPath: PactFileManager.pactDirectoryPath + "/" + self.pactContractFileName)) + let jsonObject = try JSONSerialization.jsonObject(with: fileContents, options: []) as! [String: Any] + + // Validate the final Pact contract file contains values that were specified in tests' expectations + + // MARK: - Validate Interactions + + let interactions = try XCTUnwrap(jsonObject["interactions"] as? [Any]) + let numOfExpectedInteractions = 11 + + assert( + interactions.count == numOfExpectedInteractions, + "Expected \(numOfExpectedInteractions) interactions in Pact contract but got \(interactions.count)!" + ) + + // MARK: - Validate Matchers for Interactions + + // Validate interaction "bug example" + let bugExampleInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "bug example") + // print("\nMATCHERS:\n\(matchersOne)") + let expectedMatchersOne = [ + "$.array_of_objects", + "$.array_of_objects[*].key_for_explicit_array[0]", + "$.array_of_objects[*].key_for_explicit_array[1]", + "$.array_of_objects[*].key_for_explicit_array[2]", + "$.array_of_objects[*].key_for_explicit_array[3]", + "$.array_of_objects[*].key_for_explicit_array[4]", + "$.array_of_objects[*].key_for_matcher_array", + "$.array_of_objects[*].key_for_matcher_array[*]", + "$.array_of_objects[*].key_int", + "$.array_of_objects[*].key_string", + "$.array_of_strings", + "$.array_of_strings[*]", + "$.includes_like", + ] + assert( + expectedMatchersOne.allSatisfy { expectedKey -> Bool in + bugExampleInteraction.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey + } + }, + "Not all expected generators found in Pact contract file" + ) + + // Validate interaction "a request for roles with sub-roles" + let arrayOnRootInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "a request for roles with sub-roles") + let expectedNodesForArrayOnRoot = [ + "$[*].id" + ] + assert( + expectedNodesForArrayOnRoot.allSatisfy { expectedKey -> Bool in + arrayOnRootInteraction.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey } - ) + }, + "Not all expected generators found in Pact contract file" + ) - // Validate interaction "Request for list of users in state" - let requestMatchers = try PactContractTests.extract(.matchingRules, in: .request, interactions: interactions, description: "Request for list of users in state") - let expectedMatchersTwo = [ - "$.foo" - ] - assert( - expectedMatchersTwo.allSatisfy { expectedKey -> Bool in - requestMatchers.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } + // Validate interaction "Request for animals with children" + let animalsWithChildrenInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "a request for animals with children") + let expectedNodesForAnimalsWithChildren = [ + "$.animals", + "$.animals[*].children", + "$.animals[*].children[*]", + ] + assert( + expectedNodesForAnimalsWithChildren.allSatisfy { expectedKey -> Bool in + animalsWithChildrenInteraction.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey } - , "Not all expected generators found in Pact contract file" - ) - - // Validate eachKeyLike matcher from interaction - let eachKeyLikeInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for an object with wildcard matchers") - // print("\nMATCHERS:\n\(matchersOne)") - let expectedEachKeyLikePaths = [ - "$.articles", - "$.articles[*].variants.*", - "$.articles[*].variants.*.bundles.*", - "$.articles[*].variants.*.bundles.*.description", - "$.articles[*].variants.*.bundles.*.referencedArticles", - "$.articles[*].variants.*.bundles.*.referencedArticles[*].bundleId", - ] - assert( - expectedEachKeyLikePaths.allSatisfy { expectedKey -> Bool in - eachKeyLikeInteraction.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } - }, - "Not all expected generators found in Pact contract file for eachKeyLike matcher" - ) - - // Validate eachKeyLike matcher from interaction - let eachKeyLikeSimplerInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for a simpler object with wildcard matchers") - // print("\nMATCHERS:\n\(matchersOne)") - let expectedSimplerEachKeyLikePaths = [ - "$.*", - "$.*.field1", - "$.*.field2", - ] - assert( - expectedSimplerEachKeyLikePaths.allSatisfy { expectedKey -> Bool in - eachKeyLikeSimplerInteraction.contains { generatedKey, _ -> Bool in - expectedKey == generatedKey - } - }, - "Not all expected generators found in Pact contract file for eachKeyLike matcher" - ) - - // MARK: - Validate Generators - - let responseGenerators = try extract(.generators, in: .response, interactions: interactions, description: "Request for list of users") - let expectedGeneratorsType = [ - "$.array_of_arrays[*][2]": [ - "type": "Uuid", - "format": "upper-case-hyphenated" - ] - ] + } + ) + + // Validate interaction "Request for list of users in state" + let requestMatchers = try PactContractTests.extract(.matchingRules, in: .request, interactions: interactions, description: "Request for list of users in state") + let expectedMatchersTwo = [ + "$.foo" + ] + assert( + expectedMatchersTwo.allSatisfy { expectedKey -> Bool in + requestMatchers.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey + } + } + , "Not all expected generators found in Pact contract file" + ) + + // Validate eachKeyLike matcher from interaction + let eachKeyLikeInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for an object with wildcard matchers") + // print("\nMATCHERS:\n\(matchersOne)") + let expectedEachKeyLikePaths = [ + "$.articles", + "$.articles[*].variants.*", + "$.articles[*].variants.*.bundles.*", + "$.articles[*].variants.*.bundles.*.description", + "$.articles[*].variants.*.bundles.*.referencedArticles", + "$.articles[*].variants.*.bundles.*.referencedArticles[*].bundleId", + ] + assert( + expectedEachKeyLikePaths.allSatisfy { expectedKey -> Bool in + eachKeyLikeInteraction.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey + } + }, + "Not all expected generators found in Pact contract file for eachKeyLike matcher" + ) + + // Validate eachKeyLike matcher from interaction + let eachKeyLikeSimplerInteraction = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for a simpler object with wildcard matchers") + // print("\nMATCHERS:\n\(matchersOne)") + let expectedSimplerEachKeyLikePaths = [ + "$.*", + "$.*.field1", + "$.*.field2", + ] + assert( + expectedSimplerEachKeyLikePaths.allSatisfy { expectedKey -> Bool in + eachKeyLikeSimplerInteraction.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey + } + }, + "Not all expected generators found in Pact contract file for eachKeyLike matcher" + ) + + // MARK: - Validate Generators - assert( - expectedGeneratorsType.allSatisfy { expectedKey, expectedValue -> Bool in - responseGenerators.contains { generatedKey, generatedValue -> Bool in - expectedKey == generatedKey - && expectedValue["type"] == (generatedValue as? [String: String])?["type"] - && expectedValue["format"] == (generatedValue as? [String: String])?["format"] - } - }, - "Not all expected generators found in Pact contract file" - ) - - // MARK: - Test two of same matchers used - - let twoMatchersTest = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for a simple object") - let expectedTwoMatchers = [ - "$.identifier", - "$.group_identifier", + let responseGenerators = try extract(.generators, in: .response, interactions: interactions, description: "Request for list of users") + let expectedGeneratorsType = [ + "$.array_of_arrays[*][2]": [ + "type": "Uuid", + "format": "upper-case-hyphenated" ] + ] - assert(expectedTwoMatchers.allSatisfy { expectedKey -> Bool in - twoMatchersTest.contains { generatedKey, _ -> Bool in + assert( + expectedGeneratorsType.allSatisfy { expectedKey, expectedValue -> Bool in + responseGenerators.contains { generatedKey, generatedValue -> Bool in expectedKey == generatedKey + && expectedValue["type"] == (generatedValue as? [String: String])?["type"] + && expectedValue["format"] == (generatedValue as? [String: String])?["format"] } }, - "Not all expected matchers are found in Pact interaction" - ) + "Not all expected generators found in Pact contract file" + ) - } catch { - XCTFail(error.localizedDescription) - } + // MARK: - Test two of same matchers used + + let twoMatchersTest = try PactContractTests.extract(.matchingRules, in: .response, interactions: interactions, description: "Request for a simple object") + let expectedTwoMatchers = [ + "$.identifier", + "$.group_identifier", + ] + + assert(expectedTwoMatchers.allSatisfy { expectedKey -> Bool in + twoMatchersTest.contains { generatedKey, _ -> Bool in + expectedKey == generatedKey + } + }, + "Not all expected matchers are found in Pact interaction" + ) + + } catch { + XCTFail(error.localizedDescription) + } super.tearDown() } diff --git a/Tests/Services/ProviderVerifierTests.swift b/Tests/Services/ProviderVerifierTests.swift index da2effd0..c361dfad 100644 --- a/Tests/Services/ProviderVerifierTests.swift +++ b/Tests/Services/ProviderVerifierTests.swift @@ -19,9 +19,7 @@ import XCTest @testable import PactSwift -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) +#if compiler(>=5.5) @_implementationOnly import PactSwiftMockServer #else import PactSwiftMockServer