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.runner.vm.isolate_test; | 5 library test.runner.vm.isolate_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 | 9 |
| 10 import '../../backend/group.dart'; |
10 import '../../backend/live_test.dart'; | 11 import '../../backend/live_test.dart'; |
11 import '../../backend/live_test_controller.dart'; | 12 import '../../backend/live_test_controller.dart'; |
12 import '../../backend/metadata.dart'; | 13 import '../../backend/metadata.dart'; |
13 import '../../backend/operating_system.dart'; | 14 import '../../backend/operating_system.dart'; |
14 import '../../backend/state.dart'; | 15 import '../../backend/state.dart'; |
15 import '../../backend/suite.dart'; | 16 import '../../backend/suite.dart'; |
16 import '../../backend/test.dart'; | 17 import '../../backend/test.dart'; |
17 import '../../backend/test_platform.dart'; | 18 import '../../backend/test_platform.dart'; |
18 import '../../util/remote_exception.dart'; | 19 import '../../util/remote_exception.dart'; |
19 import '../../utils.dart'; | 20 import '../../utils.dart'; |
20 | 21 |
21 /// A test in another isolate. | 22 /// A test in another isolate. |
22 class IsolateTest extends Test { | 23 class IsolateTest extends Test { |
23 final String name; | 24 final String name; |
24 final Metadata metadata; | 25 final Metadata metadata; |
25 | 26 |
26 /// The port on which to communicate with the remote test. | 27 /// The port on which to communicate with the remote test. |
27 final SendPort _sendPort; | 28 final SendPort _sendPort; |
28 | 29 |
29 IsolateTest(this.name, this.metadata, this._sendPort); | 30 IsolateTest(this.name, this.metadata, this._sendPort); |
30 | 31 |
31 LiveTest load(Suite suite) { | 32 LiveTest load(Suite suite, {Iterable<Group> groups}) { |
32 var controller; | 33 var controller; |
33 | 34 |
34 // We get a new send port for communicating with the live test, since | 35 // We get a new send port for communicating with the live test, since |
35 // [_sendPort] is only for communicating with the non-live test. This will | 36 // [_sendPort] is only for communicating with the non-live test. This will |
36 // be non-null once the test starts running. | 37 // be non-null once the test starts running. |
37 var sendPortCompleter; | 38 var sendPortCompleter; |
38 | 39 |
39 var receivePort; | 40 var receivePort; |
40 controller = new LiveTestController(suite, this, () { | 41 controller = new LiveTestController(suite, this, () { |
41 controller.setState(const State(Status.running, Result.success)); | 42 controller.setState(const State(Status.running, Result.success)); |
(...skipping 33 matching lines...) Loading... |
75 | 76 |
76 invoke(() async { | 77 invoke(() async { |
77 // If the test is still running, send it a message telling it to shut | 78 // If the test is still running, send it a message telling it to shut |
78 // down ASAP. This causes the [Invoker] to eagerly throw exceptions | 79 // down ASAP. This causes the [Invoker] to eagerly throw exceptions |
79 // whenever the test touches it. | 80 // whenever the test touches it. |
80 var sendPort = await sendPortCompleter.future; | 81 var sendPort = await sendPortCompleter.future; |
81 sendPort.send({'command': 'close'}); | 82 sendPort.send({'command': 'close'}); |
82 await controller.completer.future; | 83 await controller.completer.future; |
83 receivePort.close(); | 84 receivePort.close(); |
84 }); | 85 }); |
85 }); | 86 }, groups: groups); |
86 return controller.liveTest; | 87 return controller.liveTest; |
87 } | 88 } |
88 | 89 |
89 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { | 90 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { |
90 if (!metadata.testOn.evaluate(platform, os: os)) return null; | 91 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
91 return new IsolateTest( | 92 return new IsolateTest( |
92 name, metadata.forPlatform(platform, os: os), _sendPort); | 93 name, metadata.forPlatform(platform, os: os), _sendPort); |
93 } | 94 } |
94 } | 95 } |
OLD | NEW |