-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Tests: Fix always succeeding XCTAssertAsyncNoThrow
#8026
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
Tests: Fix always succeeding XCTAssertAsyncNoThrow
#8026
Conversation
The autoclosure expression `{ throw error }` just creates a closure that won't be executed. It leads to the test always succeeding even if the `expression` throws an error.
@swift-ci test |
@swift-ci test |
@grynspan This assertion activation revealed that Is this intentional behavior or should we set the env variable regardless of the target platform? |
It has no effect on other platforms. We set it on macOS so that XCTest doesn't try to host Swift Testing from within Xcode, like it would if you were using Xcode instead of SwiftPM. It's a bit of an inelegant hack and we may remove it in a future Xcode update. |
`SWIFT_PM_TEST_LIBRARY` was renamed to `SWIFT_TESTING_ENABLED` in swiftlang#7789, but we forgot to update the test because `XCTAssertAsyncNoThrow` always succeeded and we didn't notice the failure.
ab1e784
to
c50518d
Compare
Ok, then skip the test on non-macOS platforms |
@swift-ci test |
@swift-ci test Windows |
The autoclosure expression
{ throw error }
just creates a closure that won't be executed. It leads to the test always succeeding even if theexpression
throws an error.Fortunately, I didn't find any issue to enable the assertion except for a single case (ab1e784)