Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 15.3: fix warnings on Integration Tests #3603

Merged
merged 6 commits into from
Mar 4, 2024

Conversation

NachoSoto
Copy link
Contributor

Follow up to #3599 and #3600.

These @MainActor annotations don't work anymore because of this:

Main actor-isolated class '...' has different actor isolation from nonisolated superclass 'TestCase'; this is an error in Swift 6

They were necessary with an older version of Xcode (likely 13.x), but not anymore.

@NachoSoto NachoSoto added the test label Jan 26, 2024
@NachoSoto NachoSoto requested a review from a team January 26, 2024 18:07
@NachoSoto
Copy link
Contributor Author

NachoSoto commented Feb 5, 2024

Unfortunately removing these @MainActor (which produce a warning with Xcode 15.2) leads to crashes running the tests:

2024-01-29 17:36:56.806437+0000 BackendIntegrationTestsHostApp[10530:37574] *** Assertion failure in -[XCTestObservationCenter addTestObserver:], XCTestObservationCenter.m:108
2024-01-29 17:36:56.807637+0000 BackendIntegrationTestsHostApp[10530:37574] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Test observers can only be registered and unregistered on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000180437330 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x0000000180051274 objc_exception_throw + 56
	2   Foundation                          0x0000000180ae29b4 _userInfoForFileAndLine + 0
	3   XCTestCore                          0x0000000109bece24 -[XCTestObservationCenter addTestObserver:] + 296
	4   BackendIntegrationTests             0x000000010ad94a7c $s15SnapshotTesting28CleanCounterBetweenTestCases33_C4D615B58D7827966DB6A592ACD75CB2LLC16registerIfNeededyyFZyyXEfU_ + 216
	5   BackendIntegrationTests             0x000000010ad94adc $sIg_Ieg_TR + 20
	6   BackendIntegrationTests             0x000000010ad94b00 $sIeg_IyB_TR + 24
	7   libdispatch.dylib                   0x0000000180134708 _dispatch_client_callout + 16
	8   libdispatch.dylib                   0x0000000180144ec4 _dispatch_lane_barrier_sync_invoke_and_complete + 92

@NachoSoto
Copy link
Contributor Author

NachoSoto commented Feb 5, 2024

Oh no never mind, it's because this is broken in swift-snapshot-testing:

private class CleanCounterBetweenTestCases: NSObject, XCTestObservation {
    private static var registered = false
    private static var registerQueue = DispatchQueue(label: "co.pointfree.SnapshotTesting.testObserver")

    static func registerIfNeeded() {
      registerQueue.sync {
        if !registered {
          registered = true
          XCTestObservationCenter.shared.addTestObserver(CleanCounterBetweenTestCases())
        }
      }
    }

    func testCaseDidFinish(_ testCase: XCTestCase) {
      counterQueue.sync {
        counterMap = [:]
      }
    }
}

@NachoSoto
Copy link
Contributor Author

Blocked by this: pointfreeco/swift-snapshot-testing#661

Updating swift-snapshot-testing once that's fixed will require dropping iOS 12 support, which depends on #3615.

NachoSoto and others added 2 commits February 29, 2024 13:34
Follow up to #3599 and #3600.

These `@MainActor` annotations don't work anymore because of this:
> Main actor-isolated class '...' has different actor isolation from nonisolated superclass 'TestCase'; this is an error in Swift 6

They were necessary with an older version of Xcode (likely 13.x), but not anymore.
@MarkVillacampa MarkVillacampa changed the title Xcode 15.3 beta 1: fix warnings on Integration Tests Xcode 15.3: fix warnings on Integration Tests Mar 1, 2024
@MarkVillacampa
Copy link
Member

MarkVillacampa commented Mar 1, 2024

Submitted a PR to the swift-snapshot-testing library fixing the issue pointfreeco/swift-snapshot-testing#834

Meanwhile, we can use the fork at https://github.com/RevenueCat/swift-snapshot-testing/tree/1.12.0-fix-test-observer

@MarkVillacampa MarkVillacampa merged commit 0bb44cc into main Mar 4, 2024
24 checks passed
@MarkVillacampa MarkVillacampa deleted the xcode-15-3-integration-tests branch March 4, 2024 09:47
joshdholtz added a commit that referenced this pull request Mar 5, 2024
joshdholtz added a commit that referenced this pull request Mar 5, 2024
Reverts #3603

I _think_ this is causing a bunch of failures in SK2 tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants