Skip to content

Commit

Permalink
Don't load Crashlytics when running tests, since it trips up Thread C…
Browse files Browse the repository at this point in the history
…hecker
  • Loading branch information
cmsj committed Oct 7, 2019
1 parent 821ffd7 commit c981101
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Hammerspoon/MJAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileAnd


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
BOOL isTesting = NO;

// User is holding down Command (0x37) & Option (0x3A) keys:
if (CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,0x3A) && CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,0x37)) {
Expand Down Expand Up @@ -153,6 +154,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
if(NSClassFromString(@"XCTest") != nil) {
// Hammerspoon Tests
NSLog(@"in testing mode!");
isTesting = YES;

NSBundle *mainBundle = [NSBundle mainBundle];
NSBundle *bundle = [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/Contents/Plugins/Hammerspoon Tests.xctest", mainBundle.bundlePath]];
NSString *lsUnitPath = [bundle pathForResource:@"lsunit" ofType:@"lua"];
Expand Down Expand Up @@ -213,7 +216,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

// Enable Crashlytics, if we have an API key available
#ifdef CRASHLYTICS_API_KEY
if (HSUploadCrashData()) {
if (HSUploadCrashData() && !isTesting) {
Crashlytics *crashlytics = [Crashlytics sharedInstance];
crashlytics.debugMode = YES;
[Crashlytics startWithAPIKey:[NSString stringWithUTF8String:CRASHLYTICS_API_KEY] delegate:self];
Expand Down

0 comments on commit c981101

Please sign in to comment.