This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios, macos] Fix MGLOfflinePack invalidate crash (#15582)
- Loading branch information
Julian Rex
authored
Sep 18, 2019
1 parent
7bca176
commit 2b08c1d
Showing
12 changed files
with
354 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
// Use to catch or log assertions that occur in dispatch blocks, timers or | ||
// other asynchronous operations. | ||
@interface MGLTestAssertionHandler : NSAssertionHandler | ||
|
||
- (instancetype)initWithTestCase:(XCTestCase *)testCase; | ||
@property (nonatomic, weak) XCTestCase *testCase; | ||
|
||
// If YES, use `_XCTPreformattedFailureHandler` to "fail" the test, | ||
// otherwise log the assert. | ||
@property (nonatomic) BOOL shouldFail; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#import "MGLTestAssertionHandler.h" | ||
|
||
@implementation MGLTestAssertionHandler | ||
|
||
- (instancetype)initWithTestCase:(XCTestCase *)testCase { | ||
if ((self = [super init])) { | ||
_testCase = testCase; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)handleFailureInMethod:(SEL)selector | ||
object:(id)object | ||
file:(NSString *)fileName | ||
lineNumber:(NSInteger)line | ||
description:(NSString *)format, ... | ||
{ | ||
va_list args; | ||
va_start(args, format); | ||
NSString *description = [[NSString alloc] initWithFormat:format arguments:args]; | ||
va_end(args); | ||
|
||
NSString *condition = [NSString stringWithFormat: | ||
@"`[%@ %@]`", | ||
object, NSStringFromSelector(selector) | ||
]; | ||
|
||
if (self.testCase && self.shouldFail) { | ||
_XCTPreformattedFailureHandler(self.testCase, | ||
YES, | ||
fileName, | ||
line, | ||
condition, | ||
description | ||
); | ||
} | ||
else { | ||
NSLog(@"Assertion Failure: %@:%lu: %@ - %@", | ||
fileName, | ||
line, | ||
condition, | ||
description); | ||
} | ||
} | ||
|
||
- (void)handleFailureInFunction:(NSString *)functionName | ||
file:(NSString *)fileName | ||
lineNumber:(NSInteger)line | ||
description:(NSString *)format, ... | ||
{ | ||
va_list args; | ||
va_start(args, format); | ||
NSString *description = [[NSString alloc] initWithFormat:format arguments:args]; | ||
va_end(args); | ||
|
||
NSString *condition = [NSString stringWithFormat: | ||
@"`%@`", | ||
functionName]; | ||
|
||
if (self.testCase && self.shouldFail) { | ||
_XCTPreformattedFailureHandler(self.testCase, | ||
YES, | ||
fileName, | ||
line, | ||
condition, | ||
description); | ||
} | ||
else { | ||
NSLog(@"Assertion Failure: %@:%lu: %@ - %@", | ||
fileName, | ||
line, | ||
condition, | ||
description); | ||
} | ||
} | ||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.