Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional logging #1166

Merged
merged 2 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Tests/BugsnagBreadcrumbsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,14 @@ - (void)testCrashReportWriterConcurrency {

NSError *error = nil;
NSData *data = [NSData dataWithBytesNoCopy:buffer.buffer length:buffer.length freeWhenDone:NO];
XCTAssert([NSJSONSerialization JSONObjectWithData:data options:0 error:&error], @"%@", error);
if (![NSJSONSerialization JSONObjectWithData:data options:0 error:&error]) {
[self addAttachment:[XCTAttachment attachmentWithUniformTypeIdentifier:@"public.plain-text"
name:@"breadcrumbs.json"
payload:data
userInfo:nil]];
XCTFail(@"Breadcrumbs JSON could not be parsed: %@", error);
break;
}
}

free(buffer.buffer);
Expand Down
4 changes: 4 additions & 0 deletions features/fixtures/macos/macOSTestApp/MainWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ - (BugsnagConfiguration *)configuration {
}

- (IBAction)runScenario:(id)sender {
NSLog(@"%s %@", __PRETTY_FUNCTION__, self.scenarioName);

if (!self.scenario) {
self.scenario = [Scenario createScenarioNamed:self.scenarioName withConfig:[self configuration]];
self.scenario.eventMode = self.scenarioMetadata;
Expand All @@ -70,6 +72,8 @@ - (IBAction)runScenario:(id)sender {
}

- (IBAction)startBugsnag:(id)sender {
NSLog(@"%s %@", __PRETTY_FUNCTION__, self.scenarioName);

self.scenario = [Scenario createScenarioNamed:self.scenarioName withConfig:[self configuration]];
self.scenario.eventMode = self.scenarioMetadata;

Expand Down
19 changes: 19 additions & 0 deletions features/fixtures/macos/macOSTestApp/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

#import <Cocoa/Cocoa.h>

void NotificationCallback(CFNotificationCenterRef center, void *observer, CFNotificationName cfName, const void *object, CFDictionaryRef userInfo) {
NSString *name = (__bridge NSString *)cfName;
// Ignore high-frequency notifications
if (name == NSMenuDidAddItemNotification ||
name == NSMenuDidChangeItemNotification ||
name == NSViewDidUpdateTrackingAreasNotification ||
name == NSViewFrameDidChangeNotification ||
[name hasSuffix:@"UpdateNotification"] ||
false) {
return;
}
NSLog(@"%@", name);
}

int main(int argc, const char * argv[]) {
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
// Disable state restoration to prevent the following dialog being shown after crashes
Expand All @@ -19,5 +33,10 @@ int main(int argc, const char * argv[]) {
@"NSApplicationCrashOnExceptions": @YES,
}];

// Log (almost) all notifications to aid in diagnosing Appium test flakes
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
NULL, NotificationCallback, NULL, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);

return NSApplicationMain(argc, argv);
}