OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:stack_trace/stack_trace.dart'; | 7 import 'package:stack_trace/stack_trace.dart'; |
8 | 8 |
9 import '../frontend/expect.dart'; | 9 import '../frontend/expect.dart'; |
10 import '../runner/load_suite.dart'; | 10 import '../runner/load_suite.dart'; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 _timeoutTimer = _invokerZone.createTimer(timeout, () { | 224 _timeoutTimer = _invokerZone.createTimer(timeout, () { |
225 _outstandingCallbackZones.last.run(() { | 225 _outstandingCallbackZones.last.run(() { |
226 if (liveTest.isComplete) return; | 226 if (liveTest.isComplete) return; |
227 _handleError( | 227 _handleError( |
228 new TimeoutException( | 228 new TimeoutException( |
229 "Test timed out after ${niceDuration(timeout)}.", timeout)); | 229 "Test timed out after ${niceDuration(timeout)}.", timeout)); |
230 }); | 230 }); |
231 }); | 231 }); |
232 } | 232 } |
233 | 233 |
234 /// Marks the current test as skipped. | |
235 /// | |
236 /// If passed, [message] is emitted as a skip message. | |
237 /// | |
238 /// Note that this *does not* mark the test as complete. | |
kevmoo
2016/07/06 20:30:42
What *does* it do? Worth explaining a bit more, I
nweiz
2016/07/06 21:14:18
Done.
| |
239 void skip([String message]) { | |
240 if (liveTest.state.shouldBeDone) { | |
241 // Set the state explicitly so we don't get an extra error about the test | |
242 // failing after being complete. | |
243 _controller.setState(const State(Status.complete, Result.error)); | |
244 throw "This test was marked as skipped after it had already completed. " | |
245 "Make sure to use\n" | |
246 "[expectAsync] or the [completes] matcher when testing async code."; | |
247 } | |
248 | |
249 if (message != null) _controller.message(new Message.skip(message)); | |
250 // TODO: error if the test is already complete. | |
251 _controller.setState(const State(Status.pending, Result.skipped)); | |
252 } | |
253 | |
234 /// Notifies the invoker of an asynchronous error. | 254 /// Notifies the invoker of an asynchronous error. |
235 void _handleError(error, [StackTrace stackTrace]) { | 255 void _handleError(error, [StackTrace stackTrace]) { |
236 if (stackTrace == null) stackTrace = new Chain.current(); | 256 if (stackTrace == null) stackTrace = new Chain.current(); |
237 | 257 |
238 // Store this here because it'll change when we set the state below. | 258 // Store this here because it'll change when we set the state below. |
239 var shouldBeDone = liveTest.state.shouldBeDone; | 259 var shouldBeDone = liveTest.state.shouldBeDone; |
240 | 260 |
241 if (error is! TestFailure) { | 261 if (error is! TestFailure) { |
242 _controller.setState(const State(Status.complete, Result.error)); | 262 _controller.setState(const State(Status.complete, Result.error)); |
243 } else if (liveTest.state.result != Result.error) { | 263 } else if (liveTest.state.result != Result.error) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 _counterKey: outstandingCallbacksForBody, | 322 _counterKey: outstandingCallbacksForBody, |
303 _closableKey: true | 323 _closableKey: true |
304 }, | 324 }, |
305 zoneSpecification: new ZoneSpecification( | 325 zoneSpecification: new ZoneSpecification( |
306 print: (self, parent, zone, line) => | 326 print: (self, parent, zone, line) => |
307 _controller.message(new Message.print(line))), | 327 _controller.message(new Message.print(line))), |
308 onError: _handleError); | 328 onError: _handleError); |
309 }); | 329 }); |
310 } | 330 } |
311 } | 331 } |
OLD | NEW |