Remove the line number and file information from *all* folded frames.
Previously this was just done for core library frames, but the same
logic applies to libraries like unittest where the implementation is
irrelevant to user code.
R=rnystrom@google.com
BUG=
Review URL: https://codereview.chromium.org//967633002
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 403cd65..42c6d8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,9 @@
is always just an internal isolate message handler anyway. This
improves the readability of stack traces, especially in stack chains.
+* Remove the line numbers and specific files in all terse folded frames, not
+ just those from core libraries.
+
## 1.2.1
* Add `terse` to `LazyTrace.foldFrames()`.
diff --git a/README.md b/README.md
index 38b768d..24da03c 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,6 @@
pkg/stack_trace/lib/src/trace.dart 40:35 Trace.terse
pkg/stack_trace/lib/stack_trace.dart 24:28 format
test.dart 21:29 main.<fn>
- dart:async Timer.Timer.<fn>
## Stack Chains
@@ -194,14 +193,12 @@
test.dart 17:3 runAsync
test.dart 13:28 scheduleAsync.<fn>
- dart:isolate _RawReceivePortImpl._handleMessage
===== asynchronous gap ===========================
- dart:async _Future.then
- test.dart 13:12 scheduleAsync
- test.dart 7:18 main.<fn>
- package:stack_trace/src/chain.dart 93:20 Chain.capture
- test.dart 6:16 main
- dart:isolate _RawReceivePortImpl._handleMessage
+ dart:async _Future.then
+ test.dart 13:12 scheduleAsync
+ test.dart 7:18 main.<fn>
+ package:stack_trace Chain.capture
+ test.dart 6:16 main
That's a lot easier to understand!
diff --git a/lib/src/trace.dart b/lib/src/trace.dart
index e0cb21b..954cf45 100644
--- a/lib/src/trace.dart
+++ b/lib/src/trace.dart
@@ -252,7 +252,7 @@
if (terse) {
newFrames = newFrames.map((frame) {
- if (!frame.isCore) return frame;
+ if (!predicate(frame)) return frame;
var library = frame.library.replaceAll(_terseRegExp, '');
return new Frame(Uri.parse(library), null, null, frame.member);
}).toList();
diff --git a/test/chain_test.dart b/test/chain_test.dart
index c5f8efb..cf8a61f 100644
--- a/test/chain_test.dart
+++ b/test/chain_test.dart
@@ -590,9 +590,9 @@
expect(folded.toString(), equals(
'dart:async Zip.zap\n'
'b.dart 10:11 Bang.qux\n'
- 'a.dart 10:11 Zop.zoop\n'
+ 'a.dart Zop.zoop\n'
'===== asynchronous gap ===========================\n'
- 'a.dart 10:11 Zip.zap\n'
+ 'a.dart Zip.zap\n'
'b.dart 10:11 Zop.zoop\n'));
});
diff --git a/test/trace_test.dart b/test/trace_test.dart
index 10c931c..1887509 100644
--- a/test/trace_test.dart
+++ b/test/trace_test.dart
@@ -359,4 +359,24 @@
bar.dart 10:20 alsoNotFoo
'''));
});
+
+ test('.foldFrames with terse: true shortens folded frames', () {
+ var trace = new Trace.parse('''
+#0 notFoo (foo.dart:42:21)
+#1 fooTop (bar.dart:0:2)
+#2 fooBottom (package:foo/bar.dart:0:2)
+#3 alsoNotFoo (bar.dart:10:20)
+#4 fooTop (foo.dart:9:11)
+#5 fooBottom (foo/bar.dart:9:11)
+''');
+
+ var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'),
+ terse: true);
+ expect(folded.toString(), equals('''
+foo.dart 42:21 notFoo
+package:foo fooBottom
+bar.dart 10:20 alsoNotFoo
+foo fooBottom
+'''));
+ });
}