Fixed "Culprit" recording in Sentry (#14)

* Fix stack-trace frame ordering. In order for `Culprit` to be logged correctly it should have the latest frame at th top.

* Updated tests.

* Fix stack-frame tests.

* dartfmt over test/sentry_test.dart
This commit is contained in:
Simon Lightfoot
2018-04-26 18:16:00 +01:00
committed by Yegor
parent 3d21b1ebbe
commit f611b8061c
3 changed files with 13 additions and 12 deletions

View File

@ -24,7 +24,7 @@ List<Map<String, dynamic>> encodeStackTrace(dynamic stackTrace) {
frames.addAll(chain.traces[t].frames.map(encodeStackTraceFrame));
if (t < chain.traces.length - 1) frames.add(asynchronousGapFrameJson);
}
return frames;
return frames.reversed.toList();
}
Map<String, dynamic> encodeStackTraceFrame(Frame frame) {

View File

@ -93,7 +93,8 @@ void main() {
expect(stacktrace['frames'], const isInstanceOf<List>());
expect(stacktrace['frames'], isNotEmpty);
final Map<String, dynamic> topFrame = stacktrace['frames'].first;
final Map<String, dynamic> topFrame =
(stacktrace['frames'] as Iterable<dynamic>).last;
expect(topFrame.keys,
<String>['abs_path', 'function', 'lineno', 'in_app', 'filename']);
expect(topFrame['abs_path'], 'sentry_test.dart');

View File

@ -34,18 +34,18 @@ void main() {
'''), [
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'function': 'bar',
'lineno': 46,
'in_app': true,
'filename': 'test.dart'
},
{
'abs_path': 'test.dart',
'function': 'bar',
'lineno': 46,
'function': 'baz',
'lineno': 50,
'in_app': true,
'filename': 'test.dart'
}
},
]);
});
@ -57,8 +57,8 @@ void main() {
'''), [
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'function': 'bar',
'lineno': 46,
'in_app': true,
'filename': 'test.dart'
},
@ -67,11 +67,11 @@ void main() {
},
{
'abs_path': 'test.dart',
'function': 'bar',
'lineno': 46,
'function': 'baz',
'lineno': 50,
'in_app': true,
'filename': 'test.dart'
}
},
]);
});
});