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 unittest.invoker; | 5 library unittest.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 /// The completer to complete once the test body finishes. | 63 /// The completer to complete once the test body finishes. |
64 /// | 64 /// |
65 /// This is distinct from [_controller.completer] because a tear-down may need | 65 /// This is distinct from [_controller.completer] because a tear-down may need |
66 /// to run before the test is truly finished. | 66 /// to run before the test is truly finished. |
67 final _completer = new Completer(); | 67 final _completer = new Completer(); |
68 | 68 |
69 /// The current invoker, or `null` if none is defined. | 69 /// The current invoker, or `null` if none is defined. |
70 /// | 70 /// |
71 /// An invoker is only set within the zone scope of a running test. | 71 /// An invoker is only set within the zone scope of a running test. |
72 static Invoker get current => Zone.current[#unittest._invoker]; | 72 static Invoker get current { |
| 73 // TODO(nweiz): Use a private symbol when dart2js supports it (issue 17526). |
| 74 return Zone.current[#unittest.invoker]; |
| 75 } |
73 | 76 |
74 Invoker._(Suite suite, LocalTest test) { | 77 Invoker._(Suite suite, LocalTest test) { |
75 _controller = new LiveTestController(suite, test, _onRun); | 78 _controller = new LiveTestController(suite, test, _onRun); |
76 } | 79 } |
77 | 80 |
78 /// Tells the invoker that there's a callback running that it should wait for | 81 /// Tells the invoker that there's a callback running that it should wait for |
79 /// before considering the test successful. | 82 /// before considering the test successful. |
80 /// | 83 /// |
81 /// Each call to [addOutstandingCallback] should be followed by a call to | 84 /// Each call to [addOutstandingCallback] should be followed by a call to |
82 /// [removeOutstandingCallback] once the callbak is no longer running. Note | 85 /// [removeOutstandingCallback] once the callbak is no longer running. Note |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // avoid that. | 167 // avoid that. |
165 _completer.future.then((_) { | 168 _completer.future.then((_) { |
166 if (_test._tearDown == null) return null; | 169 if (_test._tearDown == null) return null; |
167 return new Future.sync(_test._tearDown); | 170 return new Future.sync(_test._tearDown); |
168 }).catchError(Zone.current.handleUncaughtError).then((_) { | 171 }).catchError(Zone.current.handleUncaughtError).then((_) { |
169 timer.cancel(); | 172 timer.cancel(); |
170 _controller.setState( | 173 _controller.setState( |
171 new State(Status.complete, liveTest.state.result)); | 174 new State(Status.complete, liveTest.state.result)); |
172 _controller.completer.complete(); | 175 _controller.completer.complete(); |
173 }); | 176 }); |
174 }, zoneValues: {#unittest._invoker: this}, onError: handleError); | 177 }, zoneValues: {#unittest.invoker: this}, onError: handleError); |
175 }); | 178 }); |
176 } | 179 } |
177 } | 180 } |
OLD | NEW |