Chromium Code Reviews| 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 schedule; | 5 library schedule; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:stack_trace/stack_trace.dart'; | |
| 10 import 'package:unittest/unittest.dart' as unittest; | 11 import 'package:unittest/unittest.dart' as unittest; |
| 11 | 12 |
| 12 import 'mock_clock.dart' as mock_clock; | 13 import 'mock_clock.dart' as mock_clock; |
| 13 import 'schedule_error.dart'; | 14 import 'schedule_error.dart'; |
| 14 import 'substitute_future.dart'; | 15 import 'substitute_future.dart'; |
| 15 import 'task.dart'; | 16 import 'task.dart'; |
| 16 import 'utils.dart'; | 17 import 'utils.dart'; |
| 17 import 'value_future.dart'; | 18 import 'value_future.dart'; |
| 18 | 19 |
| 19 /// The schedule of tasks to run for a single test. This has three separate task | 20 /// The schedule of tasks to run for a single test. This has three separate task |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 Function _wrapAsync(fn(arg), String description) { | 489 Function _wrapAsync(fn(arg), String description) { |
| 489 assert(_schedule.state == ScheduleState.SET_UP || isRunning); | 490 assert(_schedule.state == ScheduleState.SET_UP || isRunning); |
| 490 | 491 |
| 491 // It's possible that the queue timed out before [fn] finished. | 492 // It's possible that the queue timed out before [fn] finished. |
| 492 bool _timedOut() => | 493 bool _timedOut() => |
| 493 _schedule.currentQueue != this || pendingCallbacks.isEmpty; | 494 _schedule.currentQueue != this || pendingCallbacks.isEmpty; |
| 494 | 495 |
| 495 if (description == null) { | 496 if (description == null) { |
| 496 description = "Out-of-band operation #${_totalCallbacks}"; | 497 description = "Out-of-band operation #${_totalCallbacks}"; |
| 497 } | 498 } |
| 499 var stackString = prefixLines(terseTraceString(new Trace.current())); | |
| 500 description = "$description\n\nStack trace:\n$stackString"; | |
| 498 _totalCallbacks++; | 501 _totalCallbacks++; |
| 499 | 502 |
| 500 _pendingCallbacks.add(description); | 503 _pendingCallbacks.add(description); |
| 501 return (arg) { | 504 return (arg) { |
| 502 try { | 505 try { |
| 503 return fn(arg); | 506 return fn(arg); |
| 504 } catch (e, stackTrace) { | 507 } catch (e, stackTrace) { |
| 505 var error = new ScheduleError.from( | 508 var error = new ScheduleError.from( |
| 506 _schedule, e, stackTrace: stackTrace); | 509 _schedule, e, stackTrace: stackTrace); |
| 507 if (_timedOut()) { | 510 if (_timedOut()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 | 554 |
| 552 String toString() => name; | 555 String toString() => name; |
| 553 | 556 |
| 554 /// Returns a detailed representation of the queue as a tree of tasks. If | 557 /// Returns a detailed representation of the queue as a tree of tasks. If |
| 555 /// [highlight] is passed, that task is specially highlighted. | 558 /// [highlight] is passed, that task is specially highlighted. |
| 556 /// | 559 /// |
| 557 /// [highlight] must be a task in this queue. | 560 /// [highlight] must be a task in this queue. |
| 558 String generateTree([Task highlight]) { | 561 String generateTree([Task highlight]) { |
| 559 assert(highlight == null || highlight.queue == this); | 562 assert(highlight == null || highlight.queue == this); |
| 560 return _contents.map((task) { | 563 return _contents.map((task) { |
| 561 var taskString = prefixLines(task.toString(), | 564 var taskString = prefixLines( |
| 565 task == highlight | |
| 566 ? task.toStringWithStackTrace() | |
| 567 : task.toString(), | |
|
Bob Nystrom
2013/04/01 17:30:49
This expression is a bit dense. How about hoisting
nweiz
2013/04/01 20:46:03
Done.
| |
| 562 firstPrefix: task == highlight ? "> " : "* "); | 568 firstPrefix: task == highlight ? "> " : "* "); |
| 563 | 569 |
| 564 if (task == highlight && !task.children.isEmpty) { | 570 if (task == highlight && !task.children.isEmpty) { |
| 565 var childrenString = task.children.map((child) { | 571 var childrenString = task.children.map((child) { |
| 566 var prefix = ">"; | 572 var prefix = ">"; |
| 567 if (child.state == TaskState.ERROR) { | 573 if (child.state == TaskState.ERROR) { |
| 568 prefix = "X"; | 574 prefix = "X"; |
| 569 } else if (child.state == TaskState.SUCCESS) { | 575 } else if (child.state == TaskState.SUCCESS) { |
| 570 prefix = "*"; | 576 prefix = "*"; |
| 571 } | 577 } |
| 572 | 578 |
| 573 return prefixLines(child.toString(), | 579 return prefixLines( |
| 580 prefix == "*" | |
| 581 ? child.toString() | |
| 582 : child.toStringWithStackTrace(), | |
|
Bob Nystrom
2013/04/01 17:30:49
Ditto.
nweiz
2013/04/01 20:46:03
Done.
| |
| 574 firstPrefix: " $prefix ", prefix: " | "); | 583 firstPrefix: " $prefix ", prefix: " | "); |
| 575 }).join('\n'); | 584 }).join('\n'); |
| 576 taskString = '$taskString\n$childrenString'; | 585 taskString = '$taskString\n$childrenString'; |
| 577 } | 586 } |
| 578 | 587 |
| 579 return taskString; | 588 return taskString; |
| 580 }).join("\n"); | 589 }).join("\n"); |
| 581 } | 590 } |
| 582 } | 591 } |
| OLD | NEW |