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 '../backend/group.dart'; | 9 import '../backend/group.dart'; |
10 import '../frontend/expect.dart'; | 10 import '../frontend/expect.dart'; |
11 import '../runner/load_suite.dart'; | 11 import '../runner/load_suite.dart'; |
12 import '../utils.dart'; | 12 import '../utils.dart'; |
13 import 'closed_exception.dart'; | 13 import 'closed_exception.dart'; |
14 import 'live_test.dart'; | 14 import 'live_test.dart'; |
15 import 'live_test_controller.dart'; | 15 import 'live_test_controller.dart'; |
16 import 'metadata.dart'; | 16 import 'metadata.dart'; |
17 import 'operating_system.dart'; | 17 import 'operating_system.dart'; |
18 import 'outstanding_callback_counter.dart'; | 18 import 'outstanding_callback_counter.dart'; |
19 import 'state.dart'; | 19 import 'state.dart'; |
20 import 'suite.dart'; | 20 import 'suite.dart'; |
21 import 'test.dart'; | 21 import 'test.dart'; |
22 import 'test_platform.dart'; | 22 import 'test_platform.dart'; |
23 | 23 |
24 /// A test in this isolate. | 24 /// A test in this isolate. |
25 class LocalTest extends Test { | 25 class LocalTest extends Test { |
26 final String name; | 26 final String name; |
27 final Metadata metadata; | 27 final Metadata metadata; |
| 28 final Trace trace; |
28 | 29 |
29 /// The test body. | 30 /// The test body. |
30 final AsyncFunction _body; | 31 final AsyncFunction _body; |
31 | 32 |
32 LocalTest(this.name, this.metadata, body()) | 33 LocalTest(this.name, this.metadata, body(), {this.trace}) |
33 : _body = body; | 34 : _body = body; |
34 | 35 |
35 /// Loads a single runnable instance of this test. | 36 /// Loads a single runnable instance of this test. |
36 LiveTest load(Suite suite, {Iterable<Group> groups}) { | 37 LiveTest load(Suite suite, {Iterable<Group> groups}) { |
37 var invoker = new Invoker._(suite, this, groups: groups); | 38 var invoker = new Invoker._(suite, this, groups: groups); |
38 return invoker.liveTest; | 39 return invoker.liveTest; |
39 } | 40 } |
40 | 41 |
41 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { | 42 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { |
42 if (!metadata.testOn.evaluate(platform, os: os)) return null; | 43 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
43 return new LocalTest(name, metadata.forPlatform(platform, os: os), _body); | 44 return new LocalTest(name, metadata.forPlatform(platform, os: os), _body, |
| 45 trace: trace); |
44 } | 46 } |
45 } | 47 } |
46 | 48 |
47 /// The class responsible for managing the lifecycle of a single local test. | 49 /// The class responsible for managing the lifecycle of a single local test. |
48 /// | 50 /// |
49 /// The current invoker is accessible within the zone scope of the running test | 51 /// The current invoker is accessible within the zone scope of the running test |
50 /// using [Invoker.current]. It's used to track asynchronous callbacks and | 52 /// using [Invoker.current]. It's used to track asynchronous callbacks and |
51 /// report asynchronous errors. | 53 /// report asynchronous errors. |
52 class Invoker { | 54 class Invoker { |
53 /// The live test being driven by the invoker. | 55 /// The live test being driven by the invoker. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // outstanding callback counters at once. | 300 // outstanding callback counters at once. |
299 _counterKey: outstandingCallbacksForBody, | 301 _counterKey: outstandingCallbacksForBody, |
300 _closableKey: true | 302 _closableKey: true |
301 }, | 303 }, |
302 zoneSpecification: new ZoneSpecification( | 304 zoneSpecification: new ZoneSpecification( |
303 print: (self, parent, zone, line) => _controller.print(line)), | 305 print: (self, parent, zone, line) => _controller.print(line)), |
304 onError: _handleError); | 306 onError: _handleError); |
305 }); | 307 }); |
306 } | 308 } |
307 } | 309 } |
OLD | NEW |