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

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

Issue 12442005: pkg/unittest: fix TestCase.runningTime (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] 8 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase]
9 * and assumes unittest defines the type [TestFunction]. 9 * and assumes unittest defines the type [TestFunction].
10 */ 10 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 message = ''; 113 message = '';
114 _doneTeardown = false; 114 _doneTeardown = false;
115 var rtn = _setUp == null ? null : _setUp(); 115 var rtn = _setUp == null ? null : _setUp();
116 if (rtn is Future) { 116 if (rtn is Future) {
117 rtn.then((_) => _runTest()) 117 rtn.then((_) => _runTest())
118 .catchError((e) { 118 .catchError((e) {
119 _prepTest(); 119 _prepTest();
120 // Calling error() will result in the tearDown being done. 120 // Calling error() will result in the tearDown being done.
121 // One could debate whether tearDown should be done after 121 // One could debate whether tearDown should be done after
122 // a failed setUp. There is no right answer, but doing it 122 // a failed setUp. There is no right answer, but doing it
123 // seems to be the more conservative approach, because 123 // seems to be the more conservative approach, because
124 // unittest will not stop at a test failure. 124 // unittest will not stop at a test failure.
125 error("$description: Test setup failed: ${e.error}"); 125 error("$description: Test setup failed: ${e.error}");
126 }); 126 });
127 } else { 127 } else {
128 var f = _runTest(); 128 var f = _runTest();
129 if (f != null) { 129 if (f != null) {
130 return f; 130 return f;
131 } 131 }
132 } 132 }
133 if (result == null) { // Not complete. 133 if (result == null) { // Not complete.
(...skipping 21 matching lines...) Expand all
155 } else { 155 } else {
156 result = testResult; 156 result = testResult;
157 _config.onTestResultChanged(this); 157 _config.onTestResultChanged(this);
158 } 158 }
159 } 159 }
160 160
161 void _complete(String testResult, 161 void _complete(String testResult,
162 [String messageText = '', 162 [String messageText = '',
163 String stack = '']) { 163 String stack = '']) {
164 if (runningTime == null) { 164 if (runningTime == null) {
165 // TODO(gram): currently the duration measurement code is blocked 165 runningTime = new DateTime.now().difference(startTime);
166 // by issue 4437. When that is fixed replace the line below with:
167 // runningTime = new DateTime.now().difference(startTime);
168 runningTime = new Duration(milliseconds: 0);
169 } 166 }
170 _setResult(testResult, messageText, stack); 167 _setResult(testResult, messageText, stack);
171 if (!_doneTeardown) { 168 if (!_doneTeardown) {
172 _doneTeardown = true; 169 _doneTeardown = true;
173 if (_tearDown != null) { 170 if (_tearDown != null) {
174 var rtn = _tearDown(); 171 var rtn = _tearDown();
175 if (rtn is Future) { 172 if (rtn is Future) {
176 rtn.then((_) { 173 rtn.then((_) {
177 _notifyComplete(); 174 _notifyComplete();
178 }) 175 })
(...skipping 30 matching lines...) Expand all
209 void error(String messageText, [String stack = '']) { 206 void error(String messageText, [String stack = '']) {
210 _complete(ERROR, messageText, stack); 207 _complete(ERROR, messageText, stack);
211 } 208 }
212 209
213 void markCallbackComplete() { 210 void markCallbackComplete() {
214 if (--callbackFunctionsOutstanding == 0 && !isComplete) { 211 if (--callbackFunctionsOutstanding == 0 && !isComplete) {
215 pass(); 212 pass();
216 } 213 }
217 } 214 }
218 } 215 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698