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

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

Issue 13814017: Don't try to measure the running time if the test hasn't started yet. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment. 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 | 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) 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } else { 151 } else {
152 _result = testResult; 152 _result = testResult;
153 _config.onTestResultChanged(this); 153 _config.onTestResultChanged(this);
154 } 154 }
155 } 155 }
156 156
157 void _complete(String testResult, 157 void _complete(String testResult,
158 [String messageText = '', 158 [String messageText = '',
159 String stack = '']) { 159 String stack = '']) {
160 if (runningTime == null) { 160 if (runningTime == null) {
161 _runningTime = new DateTime.now().difference(startTime); 161 // The startTime can be `null` if an error happened during setup. In this
162 // case we simply report a running time of 0.
163 if (startTime != null) {
164 _runningTime = new DateTime.now().difference(startTime);
165 } else {
166 _runningTime = const Duration(seconds: 0);
167 }
162 } 168 }
163 _setResult(testResult, messageText, stack); 169 _setResult(testResult, messageText, stack);
164 if (!_doneTeardown) { 170 if (!_doneTeardown) {
165 _doneTeardown = true; 171 _doneTeardown = true;
166 if (tearDown != null) { 172 if (tearDown != null) {
167 var rtn = tearDown(); 173 var rtn = tearDown();
168 if (rtn is Future) { 174 if (rtn is Future) {
169 rtn.then((_) { 175 rtn.then((_) {
170 _notifyComplete(); 176 _notifyComplete();
171 }) 177 })
(...skipping 30 matching lines...) Expand all
202 void error(String messageText, [String stack = '']) { 208 void error(String messageText, [String stack = '']) {
203 _complete(ERROR, messageText, stack); 209 _complete(ERROR, messageText, stack);
204 } 210 }
205 211
206 void _markCallbackComplete() { 212 void _markCallbackComplete() {
207 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { 213 if (--_callbackFunctionsOutstanding == 0 && !isComplete) {
208 pass(); 214 pass();
209 } 215 }
210 } 216 }
211 } 217 }
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