diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 072e853..ae08a71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,15 +15,19 @@ jobs: strategy: matrix: xcode: + - 12.4 - 12.5 + - '13.0' steps: - uses: actions/checkout@v2 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - name: Print Swift version run: swift --version - - name: Run tests + - name: Run tests (Swift) run: make test-swift + - name: Run tests (platforms) + run: make test-platforms linux: name: Ubuntu diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/CustomDump_watchOS.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/CustomDump_watchOS.xcscheme new file mode 100644 index 0000000..59557b3 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/CustomDump_watchOS.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/swift-custom-dump.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/swift-custom-dump.xcscheme new file mode 100644 index 0000000..7bdac93 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/swift-custom-dump.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Makefile b/Makefile index bb50d21..1429e73 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ -test-all: test-linux test-swift +PLATFORM_IOS = iOS Simulator,name=iPhone 11 Pro Max +PLATFORM_MACOS = macOS +PLATFORM_TVOS = tvOS Simulator,name=Apple TV 4K (at 1080p) +PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 4 - 44mm + +test-all: test-linux test-swift test-platforms test-linux: docker run \ @@ -11,6 +16,41 @@ test-linux: test-swift: swift test \ --parallel + swift build \ + --configuration release + +test-platforms: + xcodebuild test \ + -scheme swift-custom-dump \ + -destination platform="$(PLATFORM_IOS)" + xcodebuild \ + -scheme swift-custom-dump \ + -configuration Release \ + -destination platform="$(PLATFORM_IOS)" + + xcodebuild test \ + -scheme swift-custom-dump \ + -destination platform="$(PLATFORM_MACOS)" + xcodebuild \ + -scheme swift-custom-dump \ + -configuration Release \ + -destination platform="$(PLATFORM_MACOS)" + + xcodebuild test \ + -scheme swift-custom-dump \ + -destination platform="$(PLATFORM_TVOS)" + xcodebuild \ + -scheme swift-custom-dump \ + -configuration Release \ + -destination platform="$(PLATFORM_TVOS)" + + xcodebuild \ + -scheme CustomDump_watchOS \ + -destination platform="$(PLATFORM_WATCHOS)" + xcodebuild \ + -scheme CustomDump_watchOS \ + -configuration Release \ + -destination platform="$(PLATFORM_WATCHOS)" format: swift format --in-place --recursive . diff --git a/Sources/CustomDump/Conformances/CoreMotion.swift b/Sources/CustomDump/Conformances/CoreMotion.swift index ecdf274..fad20bb 100644 --- a/Sources/CustomDump/Conformances/CoreMotion.swift +++ b/Sources/CustomDump/Conformances/CoreMotion.swift @@ -34,28 +34,30 @@ } } } + #endif -// @available(iOS, unavailable) -// @available(macOS, unavailable) -// @available(tvOS, unavailable) -// @available(watchOS 7.2, *) -// extension CMFallDetectionEvent.UserResolution: CustomDumpStringConvertible { -// public var customDumpDescription: String { -// switch self { -// case .confirmed: -// return "CMFallDetectionEvent.UserResolution.confirmed" -// case .dismissed: -// return "CMFallDetectionEvent.UserResolution.dismissed" -// case .rejected: -// return "CMFallDetectionEvent.UserResolution.rejected" -// case .unresponsive: -// return "CMFallDetectionEvent.UserResolution.unresponsive" -// @unknown default: -// return -// "CMFallDetectionEvent.UserResolution.(@unknown default, rawValue: \(self.rawValue))" -// } -// } -// } + #if compiler(>=5.5) + @available(iOS, unavailable) + @available(macOS, unavailable) + @available(tvOS, unavailable) + @available(watchOS 7.2, *) + extension CMFallDetectionEvent.UserResolution: CustomDumpStringConvertible { + public var customDumpDescription: String { + switch self { + case .confirmed: + return "CMFallDetectionEvent.UserResolution.confirmed" + case .dismissed: + return "CMFallDetectionEvent.UserResolution.dismissed" + case .rejected: + return "CMFallDetectionEvent.UserResolution.rejected" + case .unresponsive: + return "CMFallDetectionEvent.UserResolution.unresponsive" + @unknown default: + return + "CMFallDetectionEvent.UserResolution.(@unknown default, rawValue: \(self.rawValue))" + } + } + } #endif extension CMMotionActivityConfidence: CustomDumpStringConvertible { diff --git a/Sources/CustomDump/Conformances/GameKit.swift b/Sources/CustomDump/Conformances/GameKit.swift index ead54e2..98fc99b 100644 --- a/Sources/CustomDump/Conformances/GameKit.swift +++ b/Sources/CustomDump/Conformances/GameKit.swift @@ -1,29 +1,28 @@ #if canImport(GameKit) import GameKit - #if compiler(>=5.5) - @available(iOS 14, macOS 11, macCatalyst 14, tvOS 14, *) - extension GKAccessPoint.Location: CustomDumpStringConvertible { - public var customDumpDescription: String { - switch self { - case .bottomLeading: - return "GKAccessPoint.Location.bottomLeading" - case .bottomTrailing: - return "GKAccessPoint.Location.bottomTrailing" - case .topLeading: - return "GKAccessPoint.Location.topLeading" - case .topTrailing: - return "GKAccessPoint.Location.topTrailing" - @unknown default: - return "GKAccessPoint.Location.(@unknown default, rawValue: \(self.rawValue))" + #if !os(watchOS) + #if compiler(>=5.5) + @available(iOS 14, macOS 11, macCatalyst 14, tvOS 14, *) + extension GKAccessPoint.Location: CustomDumpStringConvertible { + public var customDumpDescription: String { + switch self { + case .bottomLeading: + return "GKAccessPoint.Location.bottomLeading" + case .bottomTrailing: + return "GKAccessPoint.Location.bottomTrailing" + case .topLeading: + return "GKAccessPoint.Location.topLeading" + case .topTrailing: + return "GKAccessPoint.Location.topTrailing" + @unknown default: + return "GKAccessPoint.Location.(@unknown default, rawValue: \(self.rawValue))" + } } } - } - #endif + #endif - #if !os(watchOS) @available(iOS 5, macCatalyst 13, macOS 10.8, tvOS 9, *) - @available(watchOS, unavailable) extension GKPlayer.PhotoSize: CustomDumpStringConvertible { public var customDumpDescription: String { switch self { diff --git a/Sources/CustomDump/Diff.swift b/Sources/CustomDump/Diff.swift index ca1e705..509d02f 100644 --- a/Sources/CustomDump/Diff.swift +++ b/Sources/CustomDump/Diff.swift @@ -25,7 +25,6 @@ /// unchanged lines. /// - Returns: A string describing any difference detected between values, or `nil` if no difference /// is detected. -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func diff(_ lhs: T, _ rhs: T, format: DiffFormat = .default) -> String? { var visitedItems: Set = [] diff --git a/Tests/CustomDumpTests/DiffTests.swift b/Tests/CustomDumpTests/DiffTests.swift index b29a311..2d5057f 100644 --- a/Tests/CustomDumpTests/DiffTests.swift +++ b/Tests/CustomDumpTests/DiffTests.swift @@ -469,16 +469,18 @@ final class DiffTests: XCTestCase { } func testNestedCustomMirror() { - XCTAssertNoDifference( - diff( - NestedDate(date: Date(timeIntervalSince1970: 0)), - NestedDate(date: Date(timeIntervalSince1970: 1)) - ), - """ - - NestedDate(date: Date(1970-01-01T00:00:00.000Z)) - + NestedDate(date: Date(1970-01-01T00:00:01.000Z)) - """ - ) + #if compiler(>=5.4) + XCTAssertNoDifference( + diff( + NestedDate(date: Date(timeIntervalSince1970: 0)), + NestedDate(date: Date(timeIntervalSince1970: 1)) + ), + """ + - NestedDate(date: Date(1970-01-01T00:00:00.000Z)) + + NestedDate(date: Date(1970-01-01T00:00:01.000Z)) + """ + ) + #endif } func testMultilineString() { diff --git a/Tests/CustomDumpTests/DumpTests.swift b/Tests/CustomDumpTests/DumpTests.swift index 5a19ec5..20b31f6 100644 --- a/Tests/CustomDumpTests/DumpTests.swift +++ b/Tests/CustomDumpTests/DumpTests.swift @@ -761,17 +761,19 @@ final class DumpTests: XCTestCase { """ ) - dump = "" - customDump( - NestedDate(date: Date(timeIntervalSince1970: 0)), - to: &dump - ) - XCTAssertNoDifference( - dump, - """ - NestedDate(date: Date(1970-01-01T00:00:00.000Z)) - """ - ) + #if compiler(>=5.4) + dump = "" + customDump( + NestedDate(date: Date(timeIntervalSince1970: 0)), + to: &dump + ) + XCTAssertNoDifference( + dump, + """ + NestedDate(date: Date(1970-01-01T00:00:00.000Z)) + """ + ) + #endif dump = "" customDump(