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

Side by Side Diff: pkg/unittest/lib/src/test_case.dart

Issue 14266009: pkg/unittest: Included traces in more places (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of unittest; 5 part of unittest;
6 6
7 /** 7 /**
8 * Represents the state for an individual unit test. 8 * Represents the state for an individual unit test.
9 * 9 *
10 * Create by calling [test] or [solo_test]. 10 * Create by calling [test] or [solo_test].
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 Future _runTest() { 76 Future _runTest() {
77 _prepTest(); 77 _prepTest();
78 // Increment/decrement callbackFunctionsOutstanding to prevent 78 // Increment/decrement callbackFunctionsOutstanding to prevent
79 // synchronous 'async' callbacks from causing the test to be 79 // synchronous 'async' callbacks from causing the test to be
80 // marked as complete before the body is completely executed. 80 // marked as complete before the body is completely executed.
81 ++_callbackFunctionsOutstanding; 81 ++_callbackFunctionsOutstanding;
82 var f = testFunction(); 82 var f = testFunction();
83 --_callbackFunctionsOutstanding; 83 --_callbackFunctionsOutstanding;
84 if (f is Future) { 84 if (f is Future) {
85 return f.then((_) => _finishTest()) 85 return f.then((_) => _finishTest())
86 .catchError((error) => fail("${error}")); 86 .catchError((error) {
87 var stack = getAttachedStackTrace(error);
88 _registerException(this, error, stack);
89 });
87 } else { 90 } else {
88 _finishTest(); 91 _finishTest();
89 return null; 92 return null;
90 } 93 }
91 } 94 }
92 95
93 void _finishTest() { 96 void _finishTest() {
94 if (result == null && _callbackFunctionsOutstanding == 0) { 97 if (result == null && _callbackFunctionsOutstanding == 0) {
95 pass(); 98 pass();
96 } 99 }
(...skipping 14 matching lines...) Expand all
111 var rtn = setUp == null ? null : setUp(); 114 var rtn = setUp == null ? null : setUp();
112 if (rtn is Future) { 115 if (rtn is Future) {
113 rtn.then((_) => _runTest()) 116 rtn.then((_) => _runTest())
114 .catchError((e) { 117 .catchError((e) {
115 _prepTest(); 118 _prepTest();
116 // Calling error() will result in the tearDown being done. 119 // Calling error() will result in the tearDown being done.
117 // One could debate whether tearDown should be done after 120 // One could debate whether tearDown should be done after
118 // a failed setUp. There is no right answer, but doing it 121 // a failed setUp. There is no right answer, but doing it
119 // seems to be the more conservative approach, because 122 // seems to be the more conservative approach, because
120 // unittest will not stop at a test failure. 123 // unittest will not stop at a test failure.
121 error("$description: Test setup failed: $e"); 124 var stack = getAttachedStackTrace(e);
125 error("$description: Test setup failed: $e", "$stack");
122 }); 126 });
123 } else { 127 } else {
124 var f = _runTest(); 128 var f = _runTest();
125 if (f != null) { 129 if (f != null) {
126 return f; 130 return f;
127 } 131 }
128 } 132 }
129 if (result == null) { // Not complete. 133 if (result == null) { // Not complete.
130 _testComplete = new Completer(); 134 _testComplete = new Completer();
131 return _testComplete.future; 135 return _testComplete.future;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void error(String messageText, [String stack = '']) { 213 void error(String messageText, [String stack = '']) {
210 _complete(ERROR, messageText, stack); 214 _complete(ERROR, messageText, stack);
211 } 215 }
212 216
213 void _markCallbackComplete() { 217 void _markCallbackComplete() {
214 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { 218 if (--_callbackFunctionsOutstanding == 0 && !isComplete) {
215 pass(); 219 pass();
216 } 220 }
217 } 221 }
218 } 222 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/unittest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698