Skip to content

Commit

Permalink
Refactor PrimitiveArrayPropertyTests a little to reduce the compiled …
Browse files Browse the repository at this point in the history
…size

The compiled object was so large that the CI machines ran out of ram building it.
  • Loading branch information
tgoyne committed Apr 1, 2020
1 parent 9961381 commit 5a5d027
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 1,530 deletions.
12 changes: 12 additions & 0 deletions Realm/TestUtils/TestUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ static void assertThrows(XCTestCase *self, dispatch_block_t block, NSString *mes
}
}

void (RLMAssertExceptionReason)(XCTestCase *self,
NSException *exception, NSString *expected, NSString *expression,
NSString *fileName, NSUInteger lineNumber) {
if (!exception) {
return;
}
if ([exception.reason rangeOfString:(expected)].location == NSNotFound) {
NSString *desc = [NSString stringWithFormat:@"The expression %@ threw an exception with reason '%@', but expected to contain '%@'", expression, exception.reason ?: @"<nil>", expected];
[self recordFailureWithDescription:desc inFile:fileName atLine:lineNumber expected:NO];
}
}

bool RLMHasCachedRealmForPath(NSString *path) {
return RLMGetAnyCachedRealmForPath(path.UTF8String);
}
16 changes: 7 additions & 9 deletions Realm/TestUtils/include/RLMAssertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void RLMAssertThrowsWithReason(XCTestCase *self,
NSString *regexString, NSString *message,
NSString *fileName, NSUInteger lineNumber);

FOUNDATION_EXTERN
void RLMAssertExceptionReason(XCTestCase *self,
NSException *exception, NSString *expected, NSString *expression,
NSString *fileName, NSUInteger lineNumber);

FOUNDATION_EXTERN bool RLMHasCachedRealmForPath(NSString *path);

#define RLMAssertThrows(expression, ...) \
Expand Down Expand Up @@ -88,17 +93,10 @@ FOUNDATION_EXTERN bool RLMHasCachedRealmForPath(NSString *path);
exception; \
})

#define RLMAssertThrowsWithReason(expression, expected, ...) \
#define RLMAssertThrowsWithReason(expression, expected) \
({ \
NSException *exception = RLMAssertThrows(expression); \
if (exception) { \
if ([exception.reason rangeOfString:(expected)].location == NSNotFound) { \
_XCTRegisterFailure(self, \
[_XCTFailureDescription(_XCTAssertion_True, 0, @#expression " (EXPR_STRING) contains " #expected) \
stringByReplacingOccurrencesOfString:@"EXPR_STRING" \
withString:exception.reason ?: @"<nil>"]); \
} \
} \
RLMAssertExceptionReason(self, exception, expected, @#expression, @"" __FILE__, __LINE__); \
exception; \
})

Expand Down
Loading

0 comments on commit 5a5d027

Please sign in to comment.