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

Unified Diff: pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.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 | « pkg/scheduled_test/lib/src/task.dart ('k') | utils/tests/pub/install/git/check_out_and_update_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart
diff --git a/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart b/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6ea9e59f9baad2ee0864a3c807437a513ee8139a
--- /dev/null
+++ b/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io' hide sleep;
+
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../metatest.dart';
+import '../utils.dart';
+
+void main() {
+ setUpTimeout();
+
+ expectTestsPass('error includes a stack trace by default', () {
+ var error;
+ test('test 1', () {
+ currentSchedule.onComplete.schedule(() {
+ error = currentSchedule.errors.first;
+ });
+
+ schedule(() => throw 'error');
+ });
+
+ test('test 2', () {
+ // There should be two stack traces: one for the thrown error, and one
+ // for the failed task (which is the captured one).
+ expect(error.toString(),
+ stringContainsInOrder(['Stack trace:', 'Stack trace:']));
+ });
+ }, passing: ['test 2']);
+
+ expectTestsPass('does not capture a stack trace if set to false', () {
+ var error;
+ test('test 1', () {
+ currentSchedule.captureStackTraces = false;
+ currentSchedule.onComplete.schedule(() {
+ error = currentSchedule.errors.first;
+ });
+
+ schedule(() => throw 'error');
+ });
+
+ test('test 2', () {
+ // There should only be the stack trace for the thrown exception, but no
+ // captured trace for the failed task.
+ var numStackTraces = 'Stack trace:'.allMatches(error.toString()).length;
+ expect(numStackTraces, equals(1));
+ });
+ }, passing: ['test 2']);
+}
« no previous file with comments | « pkg/scheduled_test/lib/src/task.dart ('k') | utils/tests/pub/install/git/check_out_and_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698