Skip to content

Commit 09a9504

Browse files
committed
Merge branch 'matrush-disableXCTestMacro'
2 parents 21cce26 + 826af40 commit 09a9504

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

Source/OCMock.xcodeproj/project.pbxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,8 +2055,8 @@
20552055
ENABLE_STRICT_OBJC_MSGSEND = YES;
20562056
GCC_NO_COMMON_BLOCKS = YES;
20572057
GCC_PREPROCESSOR_DEFINITIONS = (
2058-
"DEBUG=1",
20592058
"$(inherited)",
2059+
OCM_DISABLE_XCTEST_FEATURES,
20602060
);
20612061
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
20622062
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
@@ -2094,6 +2094,7 @@
20942094
ENABLE_NS_ASSERTIONS = NO;
20952095
ENABLE_STRICT_OBJC_MSGSEND = YES;
20962096
GCC_NO_COMMON_BLOCKS = YES;
2097+
GCC_PREPROCESSOR_DEFINITIONS = OCM_DISABLE_XCTEST_FEATURES;
20972098
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
20982099
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
20992100
INFOPLIST_FILE = "OCMock/OCMock-Info.plist";

Source/OCMock/OCMFunctions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import <objc/runtime.h>
18-
#if !TARGET_OS_WATCH
18+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
1919
#import <XCTest/XCTest.h>
2020
#endif
2121
#import "OCClassMockObject.h"
@@ -475,7 +475,7 @@ void OCMReportFailure(OCMLocation *loc, NSString *description)
475475
{
476476
id testCase = [loc testCase];
477477
#ifdef __IPHONE_14_0 // this is actually a test for Xcode 12; see issue #472
478-
#if !TARGET_OS_WATCH
478+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
479479
if((testCase != nil) && [testCase respondsToSelector:@selector(recordIssue:)])
480480
{
481481
XCTSourceCodeLocation *xctloc = [[[XCTSourceCodeLocation alloc] initWithFilePath:[loc file] lineNumber:[loc line]] autorelease];

Source/OCMock/OCMStubRecorder.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#import <objc/runtime.h>
2121

22-
#if !TARGET_OS_WATCH
22+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
2323
@class XCTestExpectation;
2424
#endif
2525

@@ -33,7 +33,7 @@
3333
- (id)andDo:(void (^)(NSInvocation *invocation))block;
3434
- (id)andForwardToRealObject;
3535

36-
#if !TARGET_OS_WATCH
36+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
3737
- (id)andFulfill:(XCTestExpectation *)expectation;
3838
#endif
3939

@@ -67,7 +67,7 @@
6767
#define andForwardToRealObject() _andForwardToRealObject()
6868
@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void);
6969

70-
#if !TARGET_OS_WATCH
70+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
7171
#define andFulfill(anExpectation) _andFulfill(anExpectation)
7272
@property (nonatomic, readonly) OCMStubRecorder *(^ _andFulfill)(XCTestExpectation *);
7373
#endif
@@ -85,6 +85,3 @@
8585
}) \
8686

8787
@end
88-
89-
90-

Source/OCMock/OCMStubRecorder.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#import "OCMNotificationPoster.h"
2525
#import "OCMRealObjectForwarder.h"
2626

27-
#if !TARGET_OS_WATCH
27+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
2828
#import <XCTest/XCTest.h>
2929
#endif
3030

@@ -101,7 +101,7 @@ - (id)andForwardToRealObject
101101
return self;
102102
}
103103

104-
#if !TARGET_OS_WATCH
104+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
105105
- (id)andFulfill:(XCTestExpectation *)expectation
106106
{
107107
return [self andDo:^(NSInvocation *invocation) {
@@ -198,7 +198,7 @@ @implementation OCMStubRecorder (Properties)
198198
return (id)[[theBlock copy] autorelease];
199199
}
200200

201-
#if !TARGET_OS_WATCH
201+
#if !defined(OCM_DISABLE_XCTEST_FEATURES)
202202

203203
@dynamic _andFulfill;
204204

Source/OCMockTests/OCMQuantifierTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ - (void)setUp
4949
expectFailure = NO;
5050
}
5151

52-
#ifdef __IPHONE_14_0 // this is actually a test for Xcode 12; see issue #472
52+
#if defined(__IPHONE_14_0) && !defined(OCM_DISABLE_XCTEST_FEATURES) // this is actually a test for Xcode 12; see issue #472
5353

5454
- (void)recordIssue:(XCTIssue *)issue
5555
{

Source/OCMockTests/OCMockObjectMacroTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ @interface OCMockObjectMacroTests : XCTestCase
108108

109109
@implementation OCMockObjectMacroTests
110110

111-
#ifdef __IPHONE_14_0 // this is actually a test for Xcode 12; see issue #472
111+
#if defined(__IPHONE_14_0) && !defined(OCM_DISABLE_XCTEST_FEATURES) // this is actually a test for Xcode 12; see issue #472
112112

113113
- (void)recordIssue:(XCTIssue *)issue
114114
{
@@ -306,6 +306,8 @@ - (NSString *)stringValueForTesting
306306
return @"TEST_STRING_FROM_TESTCASE";
307307
}
308308

309+
#ifndef OCM_DISABLE_XCTEST_FEATURES
310+
309311
- (void)testFulfillsExpectation
310312
{
311313
id mock = OCMStrictClassMock([NSString class]);
@@ -316,6 +318,8 @@ - (void)testFulfillsExpectation
316318
[self waitForExpectationsWithTimeout:0 handler:nil];
317319
}
318320

321+
#endif
322+
319323
- (void)testCanChainPropertyBasedActions
320324
{
321325
id mock = OCMPartialMock([[TestClassForMacroTesting alloc] init]);
@@ -576,7 +580,9 @@ - (void)testReturnsCorrectObjectFromInitMethodCalledOnRecorderInsideMacro
576580
OCMStub([[mock andThrow:nil] initWithString:OCMOCK_ANY]);
577581
OCMStub([[mock andPost:nil] initWithString:OCMOCK_ANY]);
578582
OCMStub([[mock andCall:nil onObject:nil] initWithString:OCMOCK_ANY]);
583+
#ifndef OCM_DISABLE_XCTEST_FEATURES
579584
OCMStub([[mock andFulfill:nil] initWithString:OCMOCK_ANY]);
585+
#endif
580586
OCMStub([[mock andDo:nil] initWithString:OCMOCK_ANY]);
581587
OCMStub([[mock andForwardToRealObject] initWithString:OCMOCK_ANY]);
582588
OCMExpect([[mock never] initWithString:OCMOCK_ANY]);

0 commit comments

Comments
 (0)