| 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 library test.backend.invoker; | 5 library test.backend.invoker; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 /// The method that's run when the test is started. | 152 /// The method that's run when the test is started. |
| 153 void _onRun() { | 153 void _onRun() { |
| 154 _controller.setState(const State(Status.running, Result.success)); | 154 _controller.setState(const State(Status.running, Result.success)); |
| 155 | 155 |
| 156 Chain.capture(() { | 156 Chain.capture(() { |
| 157 runZoned(() { | 157 runZoned(() { |
| 158 // TODO(nweiz): Make the timeout configurable. | 158 // TODO(nweiz): Make the timeout configurable. |
| 159 // TODO(nweiz): Reset this timer whenever the user's code interacts with | 159 // TODO(nweiz): Reset this timer whenever the user's code interacts with |
| 160 // the library. | 160 // the library. |
| 161 var timer = new Timer(new Duration(seconds: 30), () { | 161 var timeout = _test.metadata.timeout.apply(new Duration(seconds: 30)); |
| 162 var timer = new Timer(timeout, () { |
| 162 if (liveTest.isComplete) return; | 163 if (liveTest.isComplete) return; |
| 163 handleError( | 164 handleError( |
| 164 new TimeoutException( | 165 new TimeoutException( |
| 165 "Test timed out after 30 seconds.", | 166 "Test timed out after ${niceDuration(timeout)}.", timeout)); |
| 166 new Duration(seconds: 30))); | |
| 167 }); | 167 }); |
| 168 | 168 |
| 169 addOutstandingCallback(); | 169 addOutstandingCallback(); |
| 170 | 170 |
| 171 // Run the test asynchronously so that the "running" state change has a | 171 // Run the test asynchronously so that the "running" state change has a |
| 172 // chance to hit its event handler(s) before the test produces an error. | 172 // chance to hit its event handler(s) before the test produces an error. |
| 173 // If an error is emitted before the first state change is handled, we | 173 // If an error is emitted before the first state change is handled, we |
| 174 // can end up with [onError] callbacks firing before the corresponding | 174 // can end up with [onError] callbacks firing before the corresponding |
| 175 // [onStateChange], which violates the timing guarantees. | 175 // [onStateChange], which violates the timing guarantees. |
| 176 new Future(_test._body) | 176 new Future(_test._body) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 189 Timer.run(_controller.completer.complete); | 189 Timer.run(_controller.completer.complete); |
| 190 }); | 190 }); |
| 191 }, | 191 }, |
| 192 zoneSpecification: new ZoneSpecification( | 192 zoneSpecification: new ZoneSpecification( |
| 193 print: (self, parent, zone, line) => _controller.print(line)), | 193 print: (self, parent, zone, line) => _controller.print(line)), |
| 194 zoneValues: {#test.invoker: this}, | 194 zoneValues: {#test.invoker: this}, |
| 195 onError: handleError); | 195 onError: handleError); |
| 196 }); | 196 }); |
| 197 } | 197 } |
| 198 } | 198 } |
| OLD | NEW |