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..ea6894f87146ec38d2a9e7f4f76e90dfd0b96f15 |
--- /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.toString(); |
nweiz
2013/04/09 21:25:58
To be consistent with other tests, don't convert t
Bob Nystrom
2013/04/10 21:52:00
Done.
|
+ }); |
+ |
+ 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). |
+ var numStackTraces = new RegExp('Stack trace:').allMatches(error).length; |
+ expect(numStackTraces, equals(2)); |
nweiz
2013/04/09 21:25:58
expect(error.toString(), stringContainsInOrder('St
Bob Nystrom
2013/04/10 21:52:00
Done.
|
+ }); |
+ }, passing: ['test 2']); |
+ |
+ expectTestsPass('does not capture a stack trace if set to false', () { |
+ captureStackTraces = false; |
+ var error; |
+ test('test 1', () { |
+ currentSchedule.onComplete.schedule(() { |
+ error = currentSchedule.errors.first.toString(); |
+ }); |
+ |
+ 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 = new RegExp('Stack trace:').allMatches(error).length; |
+ expect(numStackTraces, equals(1)); |
nweiz
2013/04/09 21:25:58
expect(error.toString(), isNot(contains('Stack tra
Bob Nystrom
2013/04/10 21:52:00
It will have one instance of 'Stack trace' in it.
|
+ }); |
+ }, passing: ['test 2']); |
+} |