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/live_test.dart'; | 10 import '../../backend/live_test.dart'; |
11 import '../../backend/live_test_controller.dart'; | 11 import '../../backend/live_test_controller.dart'; |
12 import '../../backend/metadata.dart'; | 12 import '../../backend/metadata.dart'; |
| 13 import '../../backend/operating_system.dart'; |
13 import '../../backend/state.dart'; | 14 import '../../backend/state.dart'; |
14 import '../../backend/suite.dart'; | 15 import '../../backend/suite.dart'; |
15 import '../../backend/test.dart'; | 16 import '../../backend/test.dart'; |
| 17 import '../../backend/test_platform.dart'; |
16 import '../../util/remote_exception.dart'; | 18 import '../../util/remote_exception.dart'; |
17 import '../../utils.dart'; | 19 import '../../utils.dart'; |
18 | 20 |
19 /// A test in another isolate. | 21 /// A test in another isolate. |
20 class IsolateTest implements Test { | 22 class IsolateTest extends Test { |
21 final String name; | 23 final String name; |
22 final Metadata metadata; | 24 final Metadata metadata; |
23 | 25 |
24 /// The port on which to communicate with the remote test. | 26 /// The port on which to communicate with the remote test. |
25 final SendPort _sendPort; | 27 final SendPort _sendPort; |
26 | 28 |
27 IsolateTest(this.name, this.metadata, this._sendPort); | 29 IsolateTest(this.name, this.metadata, this._sendPort); |
28 | 30 |
29 /// Loads a single runnable instance of this test. | |
30 LiveTest load(Suite suite) { | 31 LiveTest load(Suite suite) { |
31 var controller; | 32 var controller; |
32 | 33 |
33 // We get a new send port for communicating with the live test, since | 34 // We get a new send port for communicating with the live test, since |
34 // [_sendPort] is only for communicating with the non-live test. This will | 35 // [_sendPort] is only for communicating with the non-live test. This will |
35 // be non-null once the test starts running. | 36 // be non-null once the test starts running. |
36 var sendPortCompleter; | 37 var sendPortCompleter; |
37 | 38 |
38 var receivePort; | 39 var receivePort; |
39 controller = new LiveTestController(suite, this, () { | 40 controller = new LiveTestController(suite, this, () { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // whenever the test touches it. | 79 // whenever the test touches it. |
79 var sendPort = await sendPortCompleter.future; | 80 var sendPort = await sendPortCompleter.future; |
80 sendPort.send({'command': 'close'}); | 81 sendPort.send({'command': 'close'}); |
81 await controller.completer.future; | 82 await controller.completer.future; |
82 receivePort.close(); | 83 receivePort.close(); |
83 }); | 84 }); |
84 }); | 85 }); |
85 return controller.liveTest; | 86 return controller.liveTest; |
86 } | 87 } |
87 | 88 |
88 Test change({String name, Metadata metadata}) { | 89 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { |
89 if (name == name && metadata == this.metadata) return this; | 90 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
90 if (name == null) name = this.name; | 91 return new IsolateTest( |
91 if (metadata == null) metadata = this.metadata; | 92 name, metadata.forPlatform(platform, os: os), _sendPort); |
92 return new IsolateTest(name, metadata, _sendPort); | |
93 } | 93 } |
94 } | 94 } |
OLD | NEW |