Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Sep 19, 2024
1 parent d63e654 commit 7e13929
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dart/lib/src/load_dart_debug_images_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LoadImageIntegrationEventProcessor implements EventProcessor {
@override
Future<SentryEvent?> apply(SentryEvent event, Hint hint) async {
final stackTrace = event.stacktrace;
if (stackTrace!.frames.any((f) => f.platform == 'native')) {
if (stackTrace != null) {
final debugImage = getAppDebugImage(stackTrace);
if (debugImage != null) {
late final DebugMeta debugMeta;
Expand All @@ -45,6 +45,12 @@ class LoadImageIntegrationEventProcessor implements EventProcessor {
}

DebugImage? getAppDebugImage(SentryStackTrace stackTrace) {
// Don't return the debug image if the stack trace doesn't have native info.
if (stackTrace.baseAddr == null ||
stackTrace.buildId == null ||
!stackTrace.frames.any((f) => f.platform == 'native')) {
return null;
}
try {
_debugImage ??= createDebugImage(stackTrace);
} catch (e, stack) {
Expand Down
20 changes: 20 additions & 0 deletions dart/test/load_dart_debug_images_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ isolate_dso_base: 10000000
expect(debugImage?.imageAddr, equals('0x10000000'));
});

test(
'Event processor does not add debug image on second stack trace without image address',
() async {
final debugImage = await fixture.parseAndProcess('''
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
build_id: 'b680cb890f9e3c12a24b172d050dec73'
isolate_dso_base: 10000000
#00 abs 000000723d6346d7 _kDartIsolateSnapshotInstructions+0x1e26d7
''');
expect(debugImage?.debugId, isNotEmpty);
expect(debugImage?.imageAddr, equals('0x10000000'));

final event = fixture.newEvent(stackTrace: fixture.parse('''
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
#00 abs 000000723d6346d7 _kDartIsolateSnapshotInstructions+0x1e26d7
'''));
final resultEvent = await fixture.process(event);
expect(resultEvent?.debugMeta?.images, isEmpty);
});

test('returns null for invalid stack trace', () async {
final event =
fixture.newEvent(stackTrace: fixture.parse('Invalid stack trace'));
Expand Down
2 changes: 1 addition & 1 deletion flutter/test/integrations/load_image_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() {
setUp(() async {
fixture = IntegrationTestFixture(LoadImageListIntegration.new);
when(fixture.binding.loadDebugImages(any))
.thenAnswer((_) async => imageList);
.thenAnswer((_) async => imageList.toList());
await fixture.registerIntegration();
});

Expand Down

0 comments on commit 7e13929

Please sign in to comment.