From c9811014a0aece637423190801d33f21f563d285 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 7 Oct 2019 13:30:17 +0100 Subject: [PATCH] Don't load Crashlytics when running tests, since it trips up Thread Checker --- Hammerspoon/MJAppDelegate.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Hammerspoon/MJAppDelegate.m b/Hammerspoon/MJAppDelegate.m index bc9d69b6a..f76577372 100644 --- a/Hammerspoon/MJAppDelegate.m +++ b/Hammerspoon/MJAppDelegate.m @@ -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)) { @@ -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"]; @@ -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];