From 4a04330a89140db80ec6c8d2873c62e8040c0a40 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 11:26:25 -0400 Subject: [PATCH 1/6] Improve CI coverage --- .github/workflows/ci.yml | 6 +- .../xcschemes/CustomDump_watchOS.xcscheme | 67 ++++++++++++++ .../xcschemes/swift-custom-dump.xcscheme | 91 +++++++++++++++++++ Makefile | 42 ++++++++- .../CustomDump/Conformances/CoreMotion.swift | 42 ++++----- Sources/CustomDump/Conformances/GameKit.swift | 5 +- Sources/CustomDump/Diff.swift | 1 - 7 files changed, 226 insertions(+), 28 deletions(-) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/CustomDump_watchOS.xcscheme create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/swift-custom-dump.xcscheme diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 072e853..565201c 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..436b0d5 100644 --- a/Sources/CustomDump/Conformances/CoreMotion.swift +++ b/Sources/CustomDump/Conformances/CoreMotion.swift @@ -35,27 +35,27 @@ } } -// @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))" -// } -// } -// } + @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..b577e06 100644 --- a/Sources/CustomDump/Conformances/GameKit.swift +++ b/Sources/CustomDump/Conformances/GameKit.swift @@ -1,7 +1,7 @@ #if canImport(GameKit) import GameKit - #if compiler(>=5.5) + #if !os(watchOS) @available(iOS 14, macOS 11, macCatalyst 14, tvOS 14, *) extension GKAccessPoint.Location: CustomDumpStringConvertible { public var customDumpDescription: String { @@ -19,11 +19,8 @@ } } } - #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 = [] From 69ef17dfc9f04477f4fd4a2165b8f2216c1d3f31 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 11:30:34 -0400 Subject: [PATCH 2/6] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 565201c..ae08a71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: xcode: - 12.4 - 12.5 - - 13.0 + - '13.0' steps: - uses: actions/checkout@v2 - name: Select Xcode ${{ matrix.xcode }} From fe5425cddb1217fda752ec6e3ef2696b937e3ddf Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 11:36:08 -0400 Subject: [PATCH 3/6] wip --- Sources/CustomDump/Conformances/GameKit.swift | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Sources/CustomDump/Conformances/GameKit.swift b/Sources/CustomDump/Conformances/GameKit.swift index b577e06..98fc99b 100644 --- a/Sources/CustomDump/Conformances/GameKit.swift +++ b/Sources/CustomDump/Conformances/GameKit.swift @@ -2,23 +2,25 @@ import GameKit #if !os(watchOS) - @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 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 @available(iOS 5, macCatalyst 13, macOS 10.8, tvOS 9, *) extension GKPlayer.PhotoSize: CustomDumpStringConvertible { From 0007965680e000e87b31366a3f3ca39465eb06e6 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 11:45:22 -0400 Subject: [PATCH 4/6] wip --- Tests/CustomDumpTests/DiffTests.swift | 35 +++++++++++++++++++-------- Tests/CustomDumpTests/DumpTests.swift | 24 +++++++++++++----- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Tests/CustomDumpTests/DiffTests.swift b/Tests/CustomDumpTests/DiffTests.swift index b29a311..764b09f 100644 --- a/Tests/CustomDumpTests/DiffTests.swift +++ b/Tests/CustomDumpTests/DiffTests.swift @@ -469,16 +469,31 @@ 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)) + """ + ) + #else + XCTAssertNoDifference( + diff( + NestedDate(date: Date(timeIntervalSince1970: 0)), + NestedDate(date: Date(timeIntervalSince1970: 1)) + ), + """ + NestedDate( + - date: Date(1970-01-01T00:00:00.000Z) + + 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..bab7618 100644 --- a/Tests/CustomDumpTests/DumpTests.swift +++ b/Tests/CustomDumpTests/DumpTests.swift @@ -766,12 +766,24 @@ final class DumpTests: XCTestCase { NestedDate(date: Date(timeIntervalSince1970: 0)), to: &dump ) - XCTAssertNoDifference( - dump, - """ - NestedDate(date: Date(1970-01-01T00:00:00.000Z)) - """ - ) + #if compiler(>=5.4) + XCTAssertNoDifference( + dump, + """ + NestedDate(date: Date(1970-01-01T00:00:00.000Z)) + """ + ) + #else + XCTAssertNoDifference( + dump, + """ + NestedDate( + date: Date(1970-01-01T00:00:00.000Z) + ) + """ + ) + #endif + dump = "" customDump( From 241b43f31d8e7850b313eb6254deeaafcbd1b029 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 11:53:00 -0400 Subject: [PATCH 5/6] wip --- Tests/CustomDumpTests/DiffTests.swift | 13 ------------- Tests/CustomDumpTests/DumpTests.swift | 20 +++++--------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/Tests/CustomDumpTests/DiffTests.swift b/Tests/CustomDumpTests/DiffTests.swift index 764b09f..2d5057f 100644 --- a/Tests/CustomDumpTests/DiffTests.swift +++ b/Tests/CustomDumpTests/DiffTests.swift @@ -480,19 +480,6 @@ final class DiffTests: XCTestCase { + NestedDate(date: Date(1970-01-01T00:00:01.000Z)) """ ) - #else - XCTAssertNoDifference( - diff( - NestedDate(date: Date(timeIntervalSince1970: 0)), - NestedDate(date: Date(timeIntervalSince1970: 1)) - ), - """ - NestedDate( - - date: Date(1970-01-01T00:00:00.000Z) - + date: Date(1970-01-01T00:00:01.000Z) - ) - """ - ) #endif } diff --git a/Tests/CustomDumpTests/DumpTests.swift b/Tests/CustomDumpTests/DumpTests.swift index bab7618..20b31f6 100644 --- a/Tests/CustomDumpTests/DumpTests.swift +++ b/Tests/CustomDumpTests/DumpTests.swift @@ -761,30 +761,20 @@ final class DumpTests: XCTestCase { """ ) - dump = "" - customDump( - NestedDate(date: Date(timeIntervalSince1970: 0)), - to: &dump - ) #if compiler(>=5.4) - XCTAssertNoDifference( - dump, - """ - NestedDate(date: Date(1970-01-01T00:00:00.000Z)) - """ + dump = "" + customDump( + NestedDate(date: Date(timeIntervalSince1970: 0)), + to: &dump ) - #else XCTAssertNoDifference( dump, """ - NestedDate( - date: Date(1970-01-01T00:00:00.000Z) - ) + NestedDate(date: Date(1970-01-01T00:00:00.000Z)) """ ) #endif - dump = "" customDump( [1, 2, 3] as NSArray, From 91b54f5849f151b9d717697deab77bf841941c30 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Mon, 23 Aug 2021 12:04:09 -0400 Subject: [PATCH 6/6] wip --- Sources/CustomDump/Conformances/CoreMotion.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/CustomDump/Conformances/CoreMotion.swift b/Sources/CustomDump/Conformances/CoreMotion.swift index 436b0d5..fad20bb 100644 --- a/Sources/CustomDump/Conformances/CoreMotion.swift +++ b/Sources/CustomDump/Conformances/CoreMotion.swift @@ -34,7 +34,9 @@ } } } + #endif + #if compiler(>=5.5) @available(iOS, unavailable) @available(macOS, unavailable) @available(tvOS, unavailable)