forked from getsentry/sentry-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_trace_test.dart
More file actions
96 lines (89 loc) · 2.59 KB
/
Copy pathstack_trace_test.dart
File metadata and controls
96 lines (89 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:sentry/src/stack_trace.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:test/test.dart';
void main() {
group('encodeStackTraceFrame', () {
test('marks dart: frames as not app frames', () {
final Frame frame = new Frame(Uri.parse('dart:core'), 1, 2, 'buzz');
expect(encodeStackTraceFrame(frame), {
'abs_path': 'dart:core',
'function': 'buzz',
'lineno': 1,
'in_app': false,
'filename': 'core'
});
});
test('cleanses absolute paths', () {
final Frame frame =
new Frame(Uri.parse('file://foo/bar/baz.dart'), 1, 2, 'buzz');
expect(encodeStackTraceFrame(frame)['abs_path'], 'baz.dart');
});
});
group('encodeStackTrace', () {
test('encodes a simple stack trace', () {
expect(encodeStackTrace('''
#0 baz (file:///pathto/test.dart:50:3)
#1 bar (file:///pathto/test.dart:46:9)
'''), [
{
'abs_path': 'test.dart',
'function': 'bar',
'lineno': 46,
'in_app': true,
'filename': 'test.dart'
},
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'in_app': true,
'filename': 'test.dart'
},
]);
});
test('encodes an asynchronous stack trace', () {
expect(encodeStackTrace('''
#0 baz (file:///pathto/test.dart:50:3)
<asynchronous suspension>
#1 bar (file:///pathto/test.dart:46:9)
'''), [
{
'abs_path': 'test.dart',
'function': 'bar',
'lineno': 46,
'in_app': true,
'filename': 'test.dart'
},
{
'abs_path': '<asynchronous suspension>',
},
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'in_app': true,
'filename': 'test.dart'
},
]);
});
test('allows changing the stack frame list before sending', () {
StackFrameFilter filter =
(list) => list.where((f) => f['abs_path'] != 'secret.dart').toList();
expect(encodeStackTrace('''
#0 baz (file:///pathto/test.dart:50:3)
#1 bar (file:///pathto/secret.dart:46:9)
''', stackFrameFilter: filter), [
{
'abs_path': 'test.dart',
'function': 'baz',
'lineno': 50,
'in_app': true,
'filename': 'test.dart'
},
]);
});
});
}