Browse Source

Fix Combine Test Failure on 2020 OSes (#3284)

* Skip specific cancellation tests on 2020 OSes.

* Reenable testing on iOS 14.

* Only build for Swift 5.1, don’t test.
Jon Shier 5 năm trước cách đây
mục cha
commit
4210ed5275
2 tập tin đã thay đổi với 29 bổ sung17 xóa
  1. 14 14
      .github/workflows/ci.yml
  2. 15 3
      Tests/CombineTests.swift

+ 14 - 14
.github/workflows/ci.yml

@@ -11,14 +11,14 @@ on:
 
 jobs:
   macOS_5_1:
-    name: Test macOS (5.1)
+    name: Build macOS (5.1)
     runs-on: macOS-latest
     env: 
       DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer
     steps:
       - uses: actions/checkout@v2
       - name: macOS (5.1)
-        run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire macOS" -destination "platform=macOS" clean test | xcpretty
+        run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire macOS" -destination "platform=macOS" clean build | xcpretty
   macOS_5_2:
     name: Test macOS (5.2)
     runs-on: macOS-latest
@@ -58,18 +58,18 @@ jobs:
       - uses: actions/checkout@v2
       - name: iOS - ${{ matrix.destination }}
         run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
-  # iOS14:
-  #   name: Test iOS 14
-  #   runs-on: macOS-latest
-  #   env:
-  #     DEVELOPER_DIR: /Applications/Xcode_12_beta.app/Contents/Developer
-  #   strategy:
-  #     matrix:
-  #       destination: ["OS=14.0,name=iPhone 11 Pro"] #, "OS=12.4,name=iPhone XS", "OS=11.4,name=iPhone X", "OS=10.3.1,name=iPhone SE"]
-  #   steps:
-  #     - uses: actions/checkout@v2
-  #     - name: iOS - ${{ matrix.destination }}
-  #       run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
+  iOS14:
+    name: Test iOS 14
+    runs-on: macOS-latest
+    env:
+      DEVELOPER_DIR: /Applications/Xcode_12_beta.app/Contents/Developer
+    strategy:
+      matrix:
+        destination: ["OS=14.0,name=iPhone 11 Pro"] #, "OS=12.4,name=iPhone XS", "OS=11.4,name=iPhone X", "OS=10.3.1,name=iPhone SE"]
+    steps:
+      - uses: actions/checkout@v2
+      - name: iOS - ${{ matrix.destination }}
+        run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
   tvOS:
     name: Test tvOS 
     runs-on: macOS-latest

+ 15 - 3
Tests/CombineTests.swift

@@ -352,7 +352,11 @@ final class DataRequestCombineTests: CombineTestCase {
     }
 
     @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
-    func testThatPublishedDataRequestCanBeCancelledAutomatically() {
+    func testThatPublishedDataRequestCanBeCancelledAutomatically() throws {
+        if #available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) {
+            throw XCTSkip("Skip on 2020 OS versions, as Combine cancellation no longer emits a value.")
+        }
+        
         // Given
         let responseReceived = expectation(description: "response should be received")
         let completionReceived = expectation(description: "stream should complete")
@@ -862,7 +866,11 @@ final class DataStreamRequestCombineTests: CombineTestCase {
     }
 
     @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
-    func testThatPublishedDataStreamRequestCanBeCancelledAutomatically() {
+    func testThatPublishedDataStreamRequestCanBeCancelledAutomatically() throws {
+        if #available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) {
+            throw XCTSkip("Skip on 2020 OS versions, as Combine cancellation no longer emits a value.")
+        }
+        
         // Given
         let responseReceived = expectation(description: "response should be received")
         let completionReceived = expectation(description: "stream should complete")
@@ -1274,7 +1282,11 @@ final class DownloadRequestCombineTests: CombineTestCase {
     }
 
     @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
-    func testThatPublishedDownloadRequestCanBeCancelledAutomatically() {
+    func testThatPublishedDownloadRequestCanBeCancelledAutomatically() throws {
+        if #available(macOS 11, iOS 14, watchOS 7, tvOS 14, *) {
+            throw XCTSkip("Skip on 2020 OS versions, as Combine cancellation no longer emits a value.")
+        }
+
         // Given
         let responseReceived = expectation(description: "response should be received")
         let completionReceived = expectation(description: "stream should complete")