| OLD | NEW |
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 * a [Future] that can be used to schedule the next test. If the test runs | 83 * a [Future] that can be used to schedule the next test. If the test runs |
| 84 * to completion synchronously, or is disabled, null is returned, to | 84 * to completion synchronously, or is disabled, null is returned, to |
| 85 * tell unittest to schedule the next test immediately. | 85 * tell unittest to schedule the next test immediately. |
| 86 */ | 86 */ |
| 87 Future _run() { | 87 Future _run() { |
| 88 if (!enabled) return new Future.value(); | 88 if (!enabled) return new Future.value(); |
| 89 | 89 |
| 90 _result = _stackTrace = null; | 90 _result = _stackTrace = null; |
| 91 _message = ''; | 91 _message = ''; |
| 92 | 92 |
| 93 var f = (setUp == null) ? new Future.value() : new Future(setUp); | 93 // Avoid calling [new Future] to avoid issue 11911. |
| 94 return f.catchError(_errorHandler('Setup')) | 94 return new Future.value().then((_) { |
| 95 if (setUp != null) return setUp(); |
| 96 }).catchError(_errorHandler('Setup')) |
| 95 .then((_) { | 97 .then((_) { |
| 96 // Skip the test if setup failed. | 98 // Skip the test if setup failed. |
| 97 if (result != null) return new Future.value(); | 99 if (result != null) return new Future.value(); |
| 98 _config.onTestStart(this); | 100 _config.onTestStart(this); |
| 99 _startTime = new DateTime.now(); | 101 _startTime = new DateTime.now(); |
| 100 _runningTime = null; | 102 _runningTime = null; |
| 101 ++_callbackFunctionsOutstanding; | 103 ++_callbackFunctionsOutstanding; |
| 102 return testFunction(); | 104 return testFunction(); |
| 103 }) | 105 }) |
| 104 .catchError(_errorHandler('Test')) | 106 .catchError(_errorHandler('Test')) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void error(String messageText, [stack]) { | 172 void error(String messageText, [stack]) { |
| 171 _complete(ERROR, messageText, stack); | 173 _complete(ERROR, messageText, stack); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void _markCallbackComplete() { | 176 void _markCallbackComplete() { |
| 175 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { | 177 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { |
| 176 pass(); | 178 pass(); |
| 177 } | 179 } |
| 178 } | 180 } |
| 179 } | 181 } |
| OLD | NEW |