Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests
: avoid race-condition in leak detection (#2806)
Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/12839/workflows/2b1e24b9-428a-40ed-bcfd-a94d7591236d/jobs/89720/steps I noticed when downloading the `.xcresult` that the tests had crashed with this: ``` Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libswiftCore.dylib 0x10bc64589 swift::runtime::AccessSet::insert(swift::runtime::Access*, void*, void*, swift::ExclusivityFlags) + 73 1 libswiftCore.dylib 0x10bc647e2 swift_beginAccess + 66 2 BackendIntegrationTests 0x13ab37c76 default argument 1 of Expectation.toEventually(_:timeout:pollInterval:description:) + 54 3 BackendIntegrationTests 0x13ab37b44 closure #1 in BaseBackendIntegrationTests.verifyPurchasesDoesNotLeak() + 276 (BaseBackendIntegrationTests.swift:167) ``` Turns out that because of the way it was written, normally `Nimble` tries to print the instance during a failure: ``` BasePurchasesTests.swift:116: error: -[UnitTests.PurchasesConfiguringTests testSettingTheDelegateAfterInitializationSendsCachedCustomerInfo] : failed - Purchases has leaked expected to eventually be nil, got <<RCPurchases: 0x125d13bf0>> ``` That crash points to a race condition inside Swift's runtime. To avoid that, this changes the expectation so `Nimble` would only try to print "expected true, got false", with our own provided description. Therefore making sure that it doesn't try to access the instance while it's being deallocated.
- Loading branch information