You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running in an async test case, the test case is not always run on the main thread, so the test fails and crashes the running suite due to this assertion.
A simple test case is to call the following code within an async test, something like:
Environment
I was using the
swiftlang/swift:nightly-5.5-focalDocker tag on the 1st December, 2021.Additional Detail from JIRA
md5: 219c66c7d78a9418491933d5732beff1
Issue Description:
It appears that XCTestCase.expectation(description: "…") calls through to XCTestCase.addExpectation(…) which asserts that it is being called from the main thread. See https://github.com/apple/swift-corelibs-xctest/blob/1b0e65c2a3453636b5b9bdf24111285426187cca/Sources/XCTest/Public/XCTestCase.swift#L63 for the implementation of this.
When running in an async test case, the test case is not always run on the main thread, so the test fails and crashes the running suite due to this assertion.
A simple test case is to call the following code within an async test, something like:
And then run it on Linux using any recent Swift 5.5 snapshot.
The same code runs fine under macOS under Xcode 13.2 beta 2, so this appears to be a difference between Swift's implementation of XCTest and Xcode's.
The text was updated successfully, but these errors were encountered: