Closed drekka closed 6 years ago
Just did a test under Xcode Version 9.4 beta (9Q1019a) and it's still not working so I'm assuming at this stage that this is not a one off 9.3 issue.
It's possible this is a known issue where catchBadInstruction is working as expected but lldb breaks at the error. I'll try to look at this later this week but I suspect the only fix is to disable debugging when you're running these tests.
Yep. Figured that might be the problem. I'm looking into alternatives to using fatalError()
which is where this all started. Thanks
You can avoid breaking to the debugger by setting the global _swift_reportFatalErrorsToDebugger
( https://github.com/apple/swift/blob/master/include/swift/Runtime/Debug.h#L218 ) to false
--you'll need to declare it extern. One place you might consider is in an override of class func setUp()
in a subclass of XCTestCase
that all your tests inherit from.
Thanks for the heads-up, @natechan, that's exactly what's needed. I wouldn't ordinarily encourage using underscore prefixed features from the Swift runtime but since this is strictly for testing purposes (NOT FOR DEPLOYED CODE), I've included it in the setUp
function of the tests so tests can proceed normally.
You've probably heard this, but I thought I'd log it anyway. Under Xcode 9.3,
catchBadInstruction()
is no longer catching SwiftFatalError()
s. This is effecting any tests which are attempting to deal with code that executes this command and frameworks which support catching fatals (Nimble'sthrowAssertion()
).The only known workaround is to turn off debugging the executable, however this kills debugging tests and is also the default setting.
So I'm hoping you can find some magic to work around the problem. I've included a simple test project which shows the problem. Just run the single unit test in Xcode 9.3 and you'll see the debugger halt on the
FatalError()
instead of returning to the unit test.test.zip