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

Unified Diff: pkg/unittest/lib/src/test_case.dart

Issue 12393017: Fix issue with async callbacks that get called synchronously while running test case function causi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/unittest/lib/src/future_matchers.dart ('k') | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/test_case.dart
===================================================================
--- pkg/unittest/lib/src/test_case.dart (revision 19336)
+++ pkg/unittest/lib/src/test_case.dart (working copy)
@@ -78,7 +78,12 @@
Future _runTest() {
_prepTest();
+ // Increment/decrement callbackFunctionsOutstanding to prevent
+ // synchronous 'async' callbacks from causing the test to be
+ // marked as complete before the body is completely executed.
+ ++callbackFunctionsOutstanding;
var f = test();
+ --callbackFunctionsOutstanding;
if (f is Future) {
f.then((_) => _finishTest())
.catchError((e) => fail("${e.error}"));
@@ -204,4 +209,10 @@
void error(String messageText, [String stack = '']) {
_complete(ERROR, messageText, stack);
}
+
+ void markCallbackComplete() {
+ if (--callbackFunctionsOutstanding == 0 && !isComplete) {
+ pass();
+ }
+ }
}
« no previous file with comments | « pkg/unittest/lib/src/future_matchers.dart ('k') | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698