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
Often times when testing code it is helpful to validate assertion cases that have preconditions or fatalErrors. A method that would aide in this endeavor would be something along the lines of XCTAssertIsFatal where a block of code is passed in that is expected to trigger a fatalError.
Normally this would mean that the code would crash. However if a signal handler for SIGILL is installed we can validate if an assertion is tripped.
This has been discussed before. StdlibUnittest takes a different approach: fork off a child process, and check its output. That's a little less dangerous—recovering from a fatalError means leaking memory at the very least.
grynspan
changed the title
[SR-5262] XCTest should have a way to validate assertions
[SR-5262] XCTest should have a way to validate assertions (e.g. assert())
Aug 17, 2023
Additional Detail from JIRA
md5: 45492463837a5115b54a5e4cdffbc273
Issue Description:
Often times when testing code it is helpful to validate assertion cases that have preconditions or fatalErrors. A method that would aide in this endeavor would be something along the lines of XCTAssertIsFatal where a block of code is passed in that is expected to trigger a fatalError.
Normally this would mean that the code would crash. However if a signal handler for SIGILL is installed we can validate if an assertion is tripped.
See https://github.com/phausler/swift-corelibs-xctest/tree/assert_fatal for a rough draft at handling fatal assertions (note this only works in a non attached debugger mode and has only been written for Darwin, however a linux port should be trivial)
The text was updated successfully, but these errors were encountered: