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

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

Issue 93143002: Make pkg/stack_trace use stack chains. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/scheduled_test.dart
diff --git a/pkg/scheduled_test/lib/scheduled_test.dart b/pkg/scheduled_test/lib/scheduled_test.dart
index 1be401cdebf58c488f9a3e5dc512ba994a0e5d71..807424f2a66cba9c657169d8c0ab5f8967a8fd69 100644
--- a/pkg/scheduled_test/lib/scheduled_test.dart
+++ b/pkg/scheduled_test/lib/scheduled_test.dart
@@ -191,6 +191,7 @@ library scheduled_test;
import 'dart:async';
+import 'package:stack_trace/stack_trace.dart';
import 'package:unittest/unittest.dart' as unittest;
import 'src/schedule.dart';
@@ -230,22 +231,26 @@ void _test(String description, void body(), Function testFn) {
_ensureInitialized();
_ensureSetUpForTopLevel();
testFn(description, () {
- var asyncDone = unittest.expectAsync0(() {});
- return currentSchedule.run(() {
- if (_setUpFn != null) _setUpFn();
- body();
- }).then((_) {
- // If we got here, the test completed successfully so tell unittest so.
- asyncDone();
- }).catchError((e) {
+ var completer = new Completer();
+
+ Chain.capture(() {
+ _currentSchedule = new Schedule();
+ return currentSchedule.run(() {
+ if (_setUpFn != null) _setUpFn();
+ body();
+ }).then(completer.complete);
+ }, onError: (e, chain) {
if (e is ScheduleError) {
assert(e.schedule.errors.contains(e));
assert(e.schedule == currentSchedule);
unittest.registerException(e.schedule.errorString());
} else {
- unittest.registerException(e);
+ unittest.registerException(e, chain);
}
+ completer.complete();
});
+
+ return completer.future;
});
}
@@ -317,7 +322,6 @@ void _setUpScheduledTest([void setUpFn()]) {
throw new StateError('There seems to be another scheduled test '
'still running.');
}
- _currentSchedule = new Schedule();
if (_setUpFn != null) {
var parentFn = _setUpFn;
_setUpFn = () { parentFn(); setUpFn(); };
@@ -332,9 +336,7 @@ void _setUpScheduledTest([void setUpFn()]) {
});
} else {
unittest.setUp(() {
- if (currentSchedule == null) {
- throw new StateError('No schedule allocated.');
- } else if (_setUpFn != null) {
+ if (_setUpFn != null) {
var parentFn = _setUpFn;
_setUpFn = () { parentFn(); setUpFn(); };
} else {
« no previous file with comments | « pkg/scheduled_test/lib/scheduled_server.dart ('k') | pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698