-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Problem
the overwritten assert and precondition functions use an internal debugOnly function to decide whether the assert/precondition failing should be handled by our facilities (in the case of debug builds) or by the Swift runtime (in the case of release builds).
this debugOnly function uses Swift's assert function to detect whether the code is running in a debug or a release context.
the issue here is that this makes XCTRuntimeAssertions unusable for release build testing, since, in that context the tests will still expect any registered precondition handlers to fire, but bc Swift.assert will become a no-op in this case, the XCTRuntimeAssertions.precondition call will get forwarded to Swift.precondition instead, crashing the test suite.
Solution
we should consider moving away basing the assert/precondition call dispatch on the behaviour of Swift.assert, and instead tie it to something else.
for example, we could dynamically determine whether the code is running in the context of a unit test, and always trigger our custom precondition handling logic in that case; we could also keep the Swift.assert-based check, and then perfom the "is running in a unit test?" check only if Swift.assert` is a no-op.
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct and Contributing Guidelines