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.
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: