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

Unified Diff: pkg/scheduled_test/lib/src/task.dart

Issue 13839023: Add flag to disable capturing stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add command line option to enable traces. Created 7 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: pkg/scheduled_test/lib/src/task.dart
diff --git a/pkg/scheduled_test/lib/src/task.dart b/pkg/scheduled_test/lib/src/task.dart
index 4ccb201f5fbe85af5f5f3ac19a7fe26021075cea..aabdbbaea7e830a5b8bc0894bba81b464e6da5f2 100644
--- a/pkg/scheduled_test/lib/src/task.dart
+++ b/pkg/scheduled_test/lib/src/task.dart
@@ -9,6 +9,7 @@ import 'dart:collection';
import 'package:stack_trace/stack_trace.dart';
+import '../scheduled_test.dart' show currentSchedule;
import 'future_group.dart';
import 'schedule.dart';
import 'utils.dart';
@@ -61,7 +62,7 @@ class Task {
Future get result => _resultCompleter.future;
final _resultCompleter = new Completer();
- final stackTrace = new Trace.current();
+ final Trace stackTrace;
Task(fn(), String description, TaskQueue queue)
: this._(fn, description, queue, null, queue.contents.length);
@@ -69,7 +70,9 @@ class Task {
Task._child(fn(), String description, Task parent)
: this._(fn, description, parent.queue, parent, parent.children.length);
- Task._(fn(), this.description, this.queue, this.parent, this._id) {
+ Task._(fn(), this.description, TaskQueue queue, this.parent, this._id)
+ : queue = queue,
+ stackTrace = queue.captureStackTraces ? new Trace.current() : null {
this.fn = () {
if (state != TaskState.WAITING) {
throw new StateError("Can't run $state task '$this'.");
@@ -121,8 +124,12 @@ class Task {
String toString() => description == null ? "#$_id" : description;
String toStringWithStackTrace() {
- var stackString = prefixLines(terseTraceString(stackTrace));
- return "$this\n\nStack trace:\n$stackString";
+ var result = toString();
+ if (stackTrace != null) {
+ var stackString = prefixLines(terseTraceString(stackTrace));
+ result += "\n\nStack trace:\n$stackString";
+ }
+ return result;
}
/// Returns a detailed representation of [queue] with this task highlighted.
« no previous file with comments | « pkg/scheduled_test/lib/src/schedule_error.dart ('k') | pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698