Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: pkg/stack_trace/test/chain_test.dart

Issue 92863003: Fix stack trace chain tests on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 chain_test; 5 library chain_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as p;
9 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import 'utils.dart'; 13 import 'utils.dart';
13 14
14 void main() { 15 void main() {
15 group('capture() with onError catches exceptions', () { 16 group('capture() with onError catches exceptions', () {
16 test('thrown in a microtask', () { 17 test('thrown in a microtask', () {
17 return captureFuture(() => inMicrotask(() => throw 'error')) 18 return captureFuture(() => inMicrotask(() => throw 'error'))
18 .then((chain) { 19 .then((chain) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 equals(new Trace.from(trace).toString())); 330 equals(new Trace.from(trace).toString()));
330 }); 331 });
331 332
332 test('Chain.parse() parses a real Chain', () { 333 test('Chain.parse() parses a real Chain', () {
333 return captureFuture(() => inMicrotask(() => throw 'error')).then((chain) { 334 return captureFuture(() => inMicrotask(() => throw 'error')).then((chain) {
334 expect(new Chain.parse(chain.toString()).toString(), 335 expect(new Chain.parse(chain.toString()).toString(),
335 equals(chain.toString())); 336 equals(chain.toString()));
336 }); 337 });
337 }); 338 });
338 339
340 var userSlashCode = p.join('user', 'code.dart');
339 group('Chain.terse', () { 341 group('Chain.terse', () {
340 test('makes each trace terse', () { 342 test('makes each trace terse', () {
341 var chain = new Chain([ 343 var chain = new Chain([
342 new Trace.parse( 344 new Trace.parse(
343 'dart:core 10:11 Foo.bar\n' 345 'dart:core 10:11 Foo.bar\n'
344 'dart:core 10:11 Bar.baz\n' 346 'dart:core 10:11 Bar.baz\n'
345 'user/code.dart 10:11 Bang.qux\n' 347 'user/code.dart 10:11 Bang.qux\n'
346 'dart:core 10:11 Zip.zap\n' 348 'dart:core 10:11 Zip.zap\n'
347 'dart:core 10:11 Zop.zoop'), 349 'dart:core 10:11 Zop.zoop'),
348 new Trace.parse( 350 new Trace.parse(
349 'user/code.dart 10:11 Bang.qux\n' 351 'user/code.dart 10:11 Bang.qux\n'
350 'dart:core 10:11 Foo.bar\n' 352 'dart:core 10:11 Foo.bar\n'
351 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 353 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n'
352 'dart:core 10:11 Zip.zap\n' 354 'dart:core 10:11 Zip.zap\n'
353 'user/code.dart 10:11 Zop.zoop') 355 'user/code.dart 10:11 Zop.zoop')
354 ]); 356 ]);
355 357
356 expect(chain.terse.toString(), equals( 358 expect(chain.terse.toString(), equals(
357 'dart:core Bar.baz\n' 359 'dart:core Bar.baz\n'
358 'user/code.dart 10:11 Bang.qux\n' 360 '$userSlashCode 10:11 Bang.qux\n'
Bob Nystrom 2013/12/02 22:37:22 The fact that this is the exact same number of cha
359 'dart:core Zop.zoop\n' 361 'dart:core Zop.zoop\n'
360 '===== asynchronous gap ===========================\n' 362 '===== asynchronous gap ===========================\n'
361 'user/code.dart 10:11 Bang.qux\n' 363 '$userSlashCode 10:11 Bang.qux\n'
362 'dart:core Zip.zap\n' 364 'dart:core Zip.zap\n'
363 'user/code.dart 10:11 Zop.zoop\n')); 365 '$userSlashCode 10:11 Zop.zoop\n'));
364 }); 366 });
365 367
366 test('eliminates internal-only traces', () { 368 test('eliminates internal-only traces', () {
367 var chain = new Chain([ 369 var chain = new Chain([
368 new Trace.parse( 370 new Trace.parse(
369 'user/code.dart 10:11 Foo.bar\n' 371 'user/code.dart 10:11 Foo.bar\n'
370 'dart:core 10:11 Bar.baz'), 372 'dart:core 10:11 Bar.baz'),
371 new Trace.parse( 373 new Trace.parse(
372 'dart:core 10:11 Foo.bar\n' 374 'dart:core 10:11 Foo.bar\n'
373 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 375 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n'
374 'dart:core 10:11 Zip.zap'), 376 'dart:core 10:11 Zip.zap'),
375 new Trace.parse( 377 new Trace.parse(
376 'user/code.dart 10:11 Foo.bar\n' 378 'user/code.dart 10:11 Foo.bar\n'
377 'dart:core 10:11 Bar.baz') 379 'dart:core 10:11 Bar.baz')
378 ]); 380 ]);
379 381
380 expect(chain.terse.toString(), equals( 382 expect(chain.terse.toString(), equals(
381 'user/code.dart 10:11 Foo.bar\n' 383 '$userSlashCode 10:11 Foo.bar\n'
382 'dart:core Bar.baz\n' 384 'dart:core Bar.baz\n'
383 '===== asynchronous gap ===========================\n' 385 '===== asynchronous gap ===========================\n'
384 'user/code.dart 10:11 Foo.bar\n' 386 '$userSlashCode 10:11 Foo.bar\n'
385 'dart:core Bar.baz\n')); 387 'dart:core Bar.baz\n'));
386 }); 388 });
387 }); 389 });
388 390
389 test('Chain.toTrace eliminates asynchronous gaps', () { 391 test('Chain.toTrace eliminates asynchronous gaps', () {
390 var trace = new Chain([ 392 var trace = new Chain([
391 new Trace.parse( 393 new Trace.parse(
392 'user/code.dart 10:11 Foo.bar\n' 394 'user/code.dart 10:11 Foo.bar\n'
393 'dart:core 10:11 Bar.baz'), 395 'dart:core 10:11 Bar.baz'),
394 new Trace.parse( 396 new Trace.parse(
395 'user/code.dart 10:11 Foo.bar\n' 397 'user/code.dart 10:11 Foo.bar\n'
396 'dart:core 10:11 Bar.baz') 398 'dart:core 10:11 Bar.baz')
397 ]).toTrace(); 399 ]).toTrace();
398 400
399 expect(trace.toString(), equals( 401 expect(trace.toString(), equals(
400 'user/code.dart 10:11 Foo.bar\n' 402 '$userSlashCode 10:11 Foo.bar\n'
401 'dart:core 10:11 Bar.baz\n' 403 'dart:core 10:11 Bar.baz\n'
402 'user/code.dart 10:11 Foo.bar\n' 404 '$userSlashCode 10:11 Foo.bar\n'
403 'dart:core 10:11 Bar.baz\n')); 405 'dart:core 10:11 Bar.baz\n'));
404 }); 406 });
405 407
406 group('Chain.track(Future)', () { 408 group('Chain.track(Future)', () {
407 test('associates the current chain with a manually-reported exception with ' 409 test('associates the current chain with a manually-reported exception with '
408 'a stack trace', () { 410 'a stack trace', () {
409 var trace = new Trace.current(); 411 var trace = new Trace.current();
410 return captureFuture(() { 412 return captureFuture(() {
411 inMicrotask(() => trackedErrorFuture(trace)); 413 inMicrotask(() => trackedErrorFuture(trace));
412 }).then((chain) { 414 }).then((chain) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 /// 611 ///
610 /// [callback] is expected to throw the string `"error"`. 612 /// [callback] is expected to throw the string `"error"`.
611 Future<Chain> captureFuture(callback()) { 613 Future<Chain> captureFuture(callback()) {
612 var completer = new Completer<Chain>(); 614 var completer = new Completer<Chain>();
613 Chain.capture(callback, onError: (error, chain) { 615 Chain.capture(callback, onError: (error, chain) {
614 expect(error, equals('error')); 616 expect(error, equals('error'));
615 completer.complete(chain); 617 completer.complete(chain);
616 }); 618 });
617 return completer.future; 619 return completer.future;
618 } 620 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698