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

Unified Diff: pkg/scheduled_test/lib/src/schedule.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
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule_error.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/src/schedule.dart
diff --git a/pkg/scheduled_test/lib/src/schedule.dart b/pkg/scheduled_test/lib/src/schedule.dart
index 88c26eb1539421ce86b6caa09a822d3d6d4b78bb..be49383f1a2fe0578000e86b383fd0e9f4c6ec0e 100644
--- a/pkg/scheduled_test/lib/src/schedule.dart
+++ b/pkg/scheduled_test/lib/src/schedule.dart
@@ -110,6 +110,14 @@ class Schedule {
/// The timer for keeping track of task timeouts. This may be null.
Timer _timeoutTimer;
+ /// If `true`, then new [Task]s will capture the current stack trace before
+ /// running. This can be set to `false` to speed up running tests since
+ /// capturing stack traces is currently quite slow. Even when set to `false`,
+ /// stack traces from *thrown* exceptions will be caught. This only disables
+ /// the eager collection of stack traces *before* an error occurs. Defaults
+ /// to `true`.
+ bool captureStackTraces = true;
+
/// Creates a new schedule with empty task queues.
Schedule() {
_tasks = new TaskQueue._("tasks", this);
@@ -309,7 +317,7 @@ class Schedule {
/// are no duplicate errors, and that all errors are wrapped in
/// [ScheduleError].
void _addError(error) {
- if (errors.contains(error)) return;
+ if (error is ScheduleError && errors.contains(error)) return;
errors.add(new ScheduleError.from(this, error));
}
}
@@ -346,6 +354,10 @@ class TaskQueue {
/// The name of the queue, for debugging purposes.
final String name;
+ /// If `true`, then new [Task]s in this queue will capture the current stack
+ /// trace before running.
+ bool get captureStackTraces => _schedule.captureStackTraces;
+
/// The [Schedule] that created this queue.
final Schedule _schedule;
@@ -496,8 +508,12 @@ class TaskQueue {
if (description == null) {
description = "Out-of-band operation #${_totalCallbacks}";
}
- var stackString = prefixLines(terseTraceString(new Trace.current()));
- description = "$description\n\nStack trace:\n$stackString";
+
+ if (captureStackTraces) {
+ var stackString = prefixLines(terseTraceString(new Trace.current()));
+ description += "\n\nStack trace:\n$stackString";
+ }
+
_totalCallbacks++;
_pendingCallbacks.add(description);
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule_error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698