On Apr 11, 2014, at 2:12 PM, Jens Alfke <j...@mooseyard.com> wrote:

> I’ve got a weird situation where an NSAssertion failure is terminating the 
> process with an “uncaught exception” even though there’s an @try block at a 
> lower stack frame ready to catch it. Stack is below. The RunTestCase() 
> function, down at frame 20, is calling the unit-test function inside of a 
> block like @try{ … } @catch(NSException *x) { … } but the catch block is 
> never entered. Instead the process just quits.
> 
> This is screwing up our automated testing, because unit tests after this 
> failing one are never run. Normally the RunTestCase function just logs the 
> exception and marks the test as failed, then continues to the next one. 
> [Note: this is a custom unit test framework, entirely unrelated to OCUnit.]
> 
> After a bit more debugging I’ve caught the _dispatch_client_callout function 
> at frame 12 calling objc_terminate after the assertion fails. I suppose it 
> has its own catch block that responds by killing the process. Is there any 
> way around this? I know the Obj-C religion is that exceptions “normally 
> shouldn’t be caught”, but this isn’t exactly a normal situation, it’s unit 
> testing.

libdispatch has its own catch-and-halt exception handler here. It does not 
allow exceptions to be thrown across its boundaries. The GCD reference says 
"Your application must catch all exceptions before returning from a block 
submitted to a dispatch queue."

You may be able to use std::set_terminate() to install a handler that records 
the test progress so your test machinery can start a new test process where it 
left off.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to