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.runner.loader; | 5 library unittest.runner.loader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 throw new LoadException(path, error); | 96 throw new LoadException(path, error); |
97 } | 97 } |
98 | 98 |
99 return Future.wait(_platforms.map((platform) { | 99 return Future.wait(_platforms.map((platform) { |
100 return new Future.sync(() { | 100 return new Future.sync(() { |
101 if (!metadata.testOn.evaluate(platform, os: currentOS)) return null; | 101 if (!metadata.testOn.evaluate(platform, os: currentOS)) return null; |
102 | 102 |
103 if (platform == TestPlatform.chrome) return _loadBrowserFile(path); | 103 if (platform == TestPlatform.chrome) return _loadBrowserFile(path); |
104 assert(platform == TestPlatform.vm); | 104 assert(platform == TestPlatform.vm); |
105 return _loadVmFile(path); | 105 return _loadVmFile(path); |
106 }).then((suite) => | 106 }).then((suite) { |
107 suite == null ? null : suite.change(metadata: metadata)); | 107 if (suite == null) return null; |
| 108 return suite.change(metadata: metadata).filter(platform, os: currentOS); |
| 109 }); |
108 })).then((suites) => suites.where((suite) => suite != null).toList()); | 110 })).then((suites) => suites.where((suite) => suite != null).toList()); |
109 } | 111 } |
110 | 112 |
111 /// Load the test suite at [path] in a browser. | 113 /// Load the test suite at [path] in a browser. |
112 Future<Suite> _loadBrowserFile(String path) => | 114 Future<Suite> _loadBrowserFile(String path) => |
113 _browserServer.then((browserServer) => browserServer.loadSuite(path)); | 115 _browserServer.then((browserServer) => browserServer.loadSuite(path)); |
114 | 116 |
115 /// Load the test suite at [path] in VM isolate. | 117 /// Load the test suite at [path] in VM isolate. |
116 Future<Suite> _loadVmFile(String path) { | 118 Future<Suite> _loadVmFile(String path) { |
117 var packageRoot = packageRootFor(path, _packageRoot); | 119 var packageRoot = packageRootFor(path, _packageRoot); |
(...skipping 20 matching lines...) Expand all Loading... |
138 if (response["type"] == "loadException") { | 140 if (response["type"] == "loadException") { |
139 return new Future.error(new LoadException(path, response["message"])); | 141 return new Future.error(new LoadException(path, response["message"])); |
140 } else if (response["type"] == "error") { | 142 } else if (response["type"] == "error") { |
141 var asyncError = RemoteException.deserialize(response["error"]); | 143 var asyncError = RemoteException.deserialize(response["error"]); |
142 return new Future.error( | 144 return new Future.error( |
143 new LoadException(path, asyncError.error), | 145 new LoadException(path, asyncError.error), |
144 asyncError.stackTrace); | 146 asyncError.stackTrace); |
145 } | 147 } |
146 | 148 |
147 return new Suite(response["tests"].map((test) { | 149 return new Suite(response["tests"].map((test) { |
148 return new IsolateTest(test['name'], test['sendPort']); | 150 var metadata = new Metadata.deserialize(test['metadata']); |
| 151 return new IsolateTest(test['name'], metadata, test['sendPort']); |
149 }), path: path, platform: "VM"); | 152 }), path: path, platform: "VM"); |
150 }); | 153 }); |
151 } | 154 } |
152 | 155 |
153 /// Closes the loader and releases all resources allocated by it. | 156 /// Closes the loader and releases all resources allocated by it. |
154 Future close() { | 157 Future close() { |
155 for (var isolate in _isolates) { | 158 for (var isolate in _isolates) { |
156 isolate.kill(); | 159 isolate.kill(); |
157 } | 160 } |
158 _isolates.clear(); | 161 _isolates.clear(); |
159 | 162 |
160 if (_browserServerCompleter == null) return new Future.value(); | 163 if (_browserServerCompleter == null) return new Future.value(); |
161 return _browserServer.then((browserServer) => browserServer.close()); | 164 return _browserServer.then((browserServer) => browserServer.close()); |
162 } | 165 } |
163 } | 166 } |
OLD | NEW |