views:

324

answers:

2

iPhone sdk 3.1.2, xcode 3.1.4, mac os x 10.5.8,

I'm a newbie using OCUnit comes with iphone sdk. The only error i get is:

error: Test rig '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk/Developer/usr/bin/otest' existed abnormally with code 139 (it may have crashed).

Does anyone know what it is? Thanks.

EDIT: I found the cause. I put very stupid code in the -dealloc of the class I was writing unit tests for. Like this:

- (void)dealloc {
    [someObject1 dealloc]; //wtf, dealloc?
    [someObject2 dealloc]; //wtf, dealloc?
    [super dealloc];
}

And sometimes this will cause code 139, sometimes 138.

+1  A: 

When I've seen this, it usually means that once of my unit tests has faulty logic and has caused otest to crash. This isn't a terribly helpful answer, because code 139 isn't a terribly helpful error code. Sorry!

Dave DeLong
Excuse me. What do you mean a "faulty logic"?
yehnan
@yehnan - something like overreleasing an object and causing a crash, dereferencing a null pointer, etc.
Dave DeLong
Thanks, as you said.
yehnan
+1  A: 

When OCUnit crashes with code 139 it really could be anything. Typically this error code occurs because it's a runtime error, not a compile time error. So, you're doing something that the compiler is fine with, but at runtime it fails.

Here are some things to take a look at when this happens, but it really could be more complex than this.
1. Check your dealloc/alloc areas make sure that these objects really do exist/are being called correctly.
2. Check your spelling, typos, etc... (two variables similarly named, but wrongly used? casts?)
3. Try to isolate your tests, meaning, work through your tests to find out which one fails. OCUnit is crashing due to a problem with your code.
4. If all else fails let the code target the simulator instead of OCUnit, you should get more meaningful slack traces that way.

Chad