OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library trace_test; | 5 library trace_test; |
6 | 6 |
7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
8 import 'package:stack_trace/stack_trace.dart'; | 8 import 'package:stack_trace/stack_trace.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 ]); | 260 ]); |
261 | 261 |
262 expect(trace.vmTrace.toString(), equals( | 262 expect(trace.vmTrace.toString(), equals( |
263 '#1 Foo.<anonymous closure> ($uri:10:20)\n' | 263 '#1 Foo.<anonymous closure> ($uri:10:20)\n' |
264 '#2 bar (http://dartlang.org/foo.dart:0:0)\n' | 264 '#2 bar (http://dartlang.org/foo.dart:0:0)\n' |
265 '#3 baz (dart:async:15:0)\n')); | 265 '#3 baz (dart:async:15:0)\n')); |
266 }); | 266 }); |
267 | 267 |
268 test('.terse folds core frames together bottom-up', () { | 268 test('.terse folds core frames together bottom-up', () { |
269 var trace = new Trace.parse(''' | 269 var trace = new Trace.parse(''' |
270 #0 notCore (foo.dart:42:21) | |
271 #1 top (dart:async/future.dart:0:2) | 270 #1 top (dart:async/future.dart:0:2) |
272 #2 bottom (dart:core/uri.dart:1:100) | 271 #2 bottom (dart:core/uri.dart:1:100) |
273 #3 alsoNotCore (bar.dart:10:20) | 272 #0 notCore (foo.dart:42:21) |
274 #4 top (dart:io:5:10) | 273 #3 top (dart:io:5:10) |
275 #5 bottom (dart:async-patch/future.dart:9:11) | 274 #4 bottom (dart:async-patch/future.dart:9:11) |
| 275 #5 alsoNotCore (bar.dart:10:20) |
276 '''); | 276 '''); |
277 | 277 |
278 expect(trace.terse.toString(), equals(''' | 278 expect(trace.terse.toString(), equals(''' |
| 279 dart:core bottom |
279 foo.dart 42:21 notCore | 280 foo.dart 42:21 notCore |
280 dart:core bottom | 281 dart:async bottom |
281 bar.dart 10:20 alsoNotCore | 282 bar.dart 10:20 alsoNotCore |
282 dart:async bottom | |
283 ''')); | 283 ''')); |
284 }); | 284 }); |
285 | 285 |
286 test('.terse folds empty async frames', () { | 286 test('.terse folds empty async frames', () { |
287 var trace = new Trace.parse(''' | 287 var trace = new Trace.parse(''' |
| 288 #0 top (dart:async/future.dart:0:2) |
| 289 #1 empty.<<anonymous closure>_async_body> (bar.dart) |
| 290 #2 bottom (dart:async-patch/future.dart:9:11) |
| 291 #3 notCore (foo.dart:42:21) |
| 292 '''); |
| 293 |
| 294 expect(trace.terse.toString(), equals(''' |
| 295 dart:async bottom |
| 296 foo.dart 42:21 notCore |
| 297 ''')); |
| 298 }); |
| 299 |
| 300 test('.terse removes the bottom-most async frame', () { |
| 301 var trace = new Trace.parse(''' |
288 #0 notCore (foo.dart:42:21) | 302 #0 notCore (foo.dart:42:21) |
289 #1 top (dart:async/future.dart:0:2) | 303 #1 top (dart:async/future.dart:0:2) |
290 #2 empty.<<anonymous closure>_async_body> (bar.dart) | 304 #2 bottom (dart:core/uri.dart:1:100) |
291 #3 bottom (dart:async-patch/future.dart:9:11) | 305 #3 top (dart:io:5:10) |
| 306 #4 bottom (dart:async-patch/future.dart:9:11) |
292 '''); | 307 '''); |
293 | 308 |
294 expect(trace.terse.toString(), equals(''' | 309 expect(trace.terse.toString(), equals(''' |
295 foo.dart 42:21 notCore | 310 foo.dart 42:21 notCore |
296 dart:async bottom | |
297 ''')); | 311 ''')); |
298 }); | 312 }); |
299 | 313 |
| 314 test(".terse won't make a trace empty", () { |
| 315 var trace = new Trace.parse(''' |
| 316 #1 top (dart:async/future.dart:0:2) |
| 317 #2 bottom (dart:core/uri.dart:1:100) |
| 318 '''); |
| 319 |
| 320 expect(trace.terse.toString(), equals(''' |
| 321 dart:core bottom |
| 322 ''')); |
| 323 }); |
| 324 |
300 test('.foldFrames folds frames together bottom-up', () { | 325 test('.foldFrames folds frames together bottom-up', () { |
301 var trace = new Trace.parse(''' | 326 var trace = new Trace.parse(''' |
302 #0 notFoo (foo.dart:42:21) | 327 #0 notFoo (foo.dart:42:21) |
303 #1 fooTop (bar.dart:0:2) | 328 #1 fooTop (bar.dart:0:2) |
304 #2 fooBottom (foo.dart:1:100) | 329 #2 fooBottom (foo.dart:1:100) |
305 #3 alsoNotFoo (bar.dart:10:20) | 330 #3 alsoNotFoo (bar.dart:10:20) |
306 #4 fooTop (dart:io/socket.dart:5:10) | 331 #4 fooTop (dart:io/socket.dart:5:10) |
307 #5 fooBottom (dart:async-patch/future.dart:9:11) | 332 #5 fooBottom (dart:async-patch/future.dart:9:11) |
308 '''); | 333 '''); |
309 | 334 |
310 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); | 335 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); |
311 expect(folded.toString(), equals(''' | 336 expect(folded.toString(), equals(''' |
312 foo.dart 42:21 notFoo | 337 foo.dart 42:21 notFoo |
313 foo.dart 1:100 fooBottom | 338 foo.dart 1:100 fooBottom |
314 bar.dart 10:20 alsoNotFoo | 339 bar.dart 10:20 alsoNotFoo |
315 dart:async-patch/future.dart 9:11 fooBottom | 340 dart:async-patch/future.dart 9:11 fooBottom |
316 ''')); | 341 ''')); |
317 }); | 342 }); |
318 | 343 |
319 test('.foldFrames with terse: true, folds core frames as well', () { | 344 test('.foldFrames with terse: true folds core frames as well', () { |
320 var trace = new Trace.parse(''' | 345 var trace = new Trace.parse(''' |
321 #0 notFoo (foo.dart:42:21) | 346 #0 notFoo (foo.dart:42:21) |
322 #1 fooTop (bar.dart:0:2) | 347 #1 fooTop (bar.dart:0:2) |
323 #2 coreBottom (dart:async/future.dart:0:2) | 348 #2 coreBottom (dart:async/future.dart:0:2) |
324 #3 alsoNotFoo (bar.dart:10:20) | 349 #3 alsoNotFoo (bar.dart:10:20) |
325 #4 fooTop (foo.dart:9:11) | 350 #4 fooTop (foo.dart:9:11) |
326 #5 coreBottom (dart:async-patch/future.dart:9:11) | 351 #5 coreBottom (dart:async-patch/future.dart:9:11) |
327 '''); | 352 '''); |
328 | 353 |
329 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'), | 354 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo'), |
330 terse: true); | 355 terse: true); |
331 expect(folded.toString(), equals(''' | 356 expect(folded.toString(), equals(''' |
332 foo.dart 42:21 notFoo | 357 foo.dart 42:21 notFoo |
333 dart:async coreBottom | 358 dart:async coreBottom |
334 bar.dart 10:20 alsoNotFoo | 359 bar.dart 10:20 alsoNotFoo |
335 dart:async coreBottom | |
336 ''')); | 360 ''')); |
337 }); | 361 }); |
338 } | 362 } |
OLD | NEW |