OCMock Error with Clang

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

OCMock Error with Clang

Postby theory » 15 Nov 2010, 23:28

Howdy,

I've got this line in my tests:

Code: Select all
    [[[mock stub] andCall:@selector(fakeUpdate:) onObject:self] executeUpdate:[OCMArg any]];


Works fine with GCC and LLVM GCC, but with LLVM Compiler 1.6 (Clang) I get this error:

Code: Select all
Test Case '-[FeedParserTest testEntryParsing]' started.
2010-11-15 09:31:20.808 otest[93605:903] -[NSInvocation getArgumentAtIndexAsObject:]: unrecognized selector sent to instance 0xe97430
2010-11-15 09:31:20.809 otest[93605:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSInvocation getArgumentAtIndexAsObject:]: unrecognized selector sent to instance 0xe97430'
*** Call stack at first throw:
(
   0   CoreFoundation                      0x004d9be9 __exceptionPreprocess + 185
   1   libobjc.A.dylib                     0x002ce5c2 objc_exception_throw + 47
   2   CoreFoundation                      0x004db6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
   3   CoreFoundation                      0x0044b366 ___forwarding___ + 966
   4   CoreFoundation                      0x0044af22 _CF_forwarding_prep_0 + 50
   5   UnitTesting                         0x00d6702f -[OCMockRecorder matchesInvocation:] + 179
   6   UnitTesting                         0x00d67864 -[OCMockObject handleInvocation:] + 91
   7   UnitTesting                         0x00d66a35 -[OCPartialMockObject forwardInvocationForRealObject:] + 77
   8   CoreFoundation                      0x0044b404 ___forwarding___ + 1124
   9   CoreFoundation                      0x0044af22 _CF_forwarding_prep_0 + 50
   10  UnitTesting                         0x00d482eb -[FMDatabase rollback] + 59
   11  UnitTesting                         0x00d55658 -[DBTestBase tearDown] + 72
   12  SenTestingKit                       0x20103d1f -[SenTestCase performTest:] + 192
   13  SenTestingKit                       0x2010344b -[SenTest run] + 88
   14  SenTestingKit                       0x20105fa7 -[SenTestSuite performTest:] + 115
   15  SenTestingKit                       0x2010344b -[SenTest run] + 88
   16  SenTestingKit                       0x20105fa7 -[SenTestSuite performTest:] + 115
   17  SenTestingKit                       0x2010344b -[SenTest run] + 88
   18  SenTestingKit                       0x20105871 +[SenTestProbe runTests:] + 174
   19  otest                               0x000023b3 0x0 + 9139
   20  otest                               0x000025de 0x0 + 9694
   21  otest                               0x00002086 0x0 + 8326
   22  otest                               0x00002035 0x0 + 8245
   23  ???                                 0x00000003 0x0 + 3
)
terminate called after throwing an instance of 'NSException'
/Developer/Tools/RunPlatformUnitTests.include: line 415: 93605 Abort trap              "${THIN_TEST_RIG}" "${OTHER_TEST_FLAGS}" "${TEST_BUNDLE_PATH}"
/Developer/Tools/RunPlatformUnitTests.include:451: error: Test rig '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/Developer/usr/bin/otest' exited abnormally with code 134 (it may have crashed).


I'm running r70 from http://svn.mulle-kybernetik.com/OCMock/trunk on Xcode 3.2.5 on iOS 4.2.

Thanks,

David
theory
 
Posts: 1
Joined: 05 Sep 2010, 00:21

Re: OCMock Error with Clang

Postby erik » 28 Jan 2011, 20:44

Assuming that this was about an iOS project I've recreated such a setup. The behaviour I get matches your description. However, when I move the test into the OCMock framework's source it passes, even when using the LLVM compiler.

What is also noteworthy is that the method call that is causing the problem is a call to a method defined in a category in the OCMock framework.

These observations make me believe that this is yet another issue with the linker when using categories and static libraries.

Given that this isn't necessarily a common setup and it's an area Apple is working in, I'll leave this as is, and see what the next version of the SDK brings. That said, I've now added a small check to the initialiser of OCMockObject that raises an exception with a message describing the problem if the category methods aren't present.

erik
erik
 
Posts: 90
Joined: 10 Oct 2009, 15:22
Location: Hamburg, Germany


Return to OCMock