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.backend.invoker; | 5 library unittest.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 |
11 import '../frontend/expect.dart'; | 11 import '../frontend/expect.dart'; |
12 import '../utils.dart'; | 12 import '../utils.dart'; |
13 import 'live_test.dart'; | 13 import 'live_test.dart'; |
14 import 'live_test_controller.dart'; | 14 import 'live_test_controller.dart'; |
| 15 import 'metadata.dart'; |
15 import 'state.dart'; | 16 import 'state.dart'; |
16 import 'suite.dart'; | 17 import 'suite.dart'; |
17 import 'test.dart'; | 18 import 'test.dart'; |
18 | 19 |
19 /// A test in this isolate. | 20 /// A test in this isolate. |
20 class LocalTest implements Test { | 21 class LocalTest implements Test { |
21 /// The name of the test. | |
22 final String name; | 22 final String name; |
| 23 final Metadata metadata; |
23 | 24 |
24 /// The test body. | 25 /// The test body. |
25 final AsyncFunction _body; | 26 final AsyncFunction _body; |
26 | 27 |
27 /// The callback used to clean up after the test. | 28 /// The callback used to clean up after the test. |
28 /// | 29 /// |
29 /// This is separated out from [_body] because it needs to run once the test's | 30 /// This is separated out from [_body] because it needs to run once the test's |
30 /// asynchronous computation has finished, even if that's different from the | 31 /// asynchronous computation has finished, even if that's different from the |
31 /// completion of the main body of the test. | 32 /// completion of the main body of the test. |
32 final AsyncFunction _tearDown; | 33 final AsyncFunction _tearDown; |
33 | 34 |
34 LocalTest(this.name, body(), {tearDown()}) | 35 LocalTest(this.name, this.metadata, body(), {tearDown()}) |
35 : _body = body, | 36 : _body = body, |
36 _tearDown = tearDown; | 37 _tearDown = tearDown; |
37 | 38 |
38 /// Loads a single runnable instance of this test. | 39 /// Loads a single runnable instance of this test. |
39 LiveTest load(Suite suite) { | 40 LiveTest load(Suite suite) { |
40 var invoker = new Invoker._(suite, this); | 41 var invoker = new Invoker._(suite, this); |
41 return invoker.liveTest; | 42 return invoker.liveTest; |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 new State(Status.complete, liveTest.state.result)); | 175 new State(Status.complete, liveTest.state.result)); |
175 | 176 |
176 // Use [Timer.run] here to avoid starving the DOM or other | 177 // Use [Timer.run] here to avoid starving the DOM or other |
177 // non-microtask events. | 178 // non-microtask events. |
178 Timer.run(_controller.completer.complete); | 179 Timer.run(_controller.completer.complete); |
179 }); | 180 }); |
180 }, zoneValues: {#unittest.invoker: this}, onError: handleError); | 181 }, zoneValues: {#unittest.invoker: this}, onError: handleError); |
181 }); | 182 }); |
182 } | 183 } |
183 } | 184 } |
OLD | NEW |