| 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.loader; | 5 library test.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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 for (var platform in _platforms) { | 155 for (var platform in _platforms) { |
| 156 if (!suiteMetadata.testOn.evaluate(platform, os: currentOS)) continue; | 156 if (!suiteMetadata.testOn.evaluate(platform, os: currentOS)) continue; |
| 157 | 157 |
| 158 var metadata = suiteMetadata.forPlatform(platform, os: currentOS); | 158 var metadata = suiteMetadata.forPlatform(platform, os: currentOS); |
| 159 | 159 |
| 160 // Don't load a skipped suite. | 160 // Don't load a skipped suite. |
| 161 if (metadata.skip) { | 161 if (metadata.skip) { |
| 162 yield new LoadSuite.forSuite(new Suite([ | 162 yield new LoadSuite.forSuite(new Suite([ |
| 163 new LocalTest(path, metadata, () {}) | 163 new LocalTest(path, metadata, () {}) |
| 164 ], path: path, platform: platform.name, metadata: metadata)); | 164 ], path: path, platform: platform, metadata: metadata)); |
| 165 continue; | 165 continue; |
| 166 } | 166 } |
| 167 | 167 |
| 168 var name = (platform.isJS ? "compiling " : "loading ") + path; | 168 var name = (platform.isJS ? "compiling " : "loading ") + path; |
| 169 yield new LoadSuite(name, () { | 169 yield new LoadSuite(name, () { |
| 170 return platform == TestPlatform.vm | 170 return platform == TestPlatform.vm |
| 171 ? _loadVmFile(path, metadata) | 171 ? _loadVmFile(path, metadata) |
| 172 : _loadBrowserFile(path, platform, metadata); | 172 : _loadBrowserFile(path, platform, metadata); |
| 173 }, platform: platform.name); | 173 }, platform: platform); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 /// Load the test suite at [path] in [platform]. | 177 /// Load the test suite at [path] in [platform]. |
| 178 /// | 178 /// |
| 179 /// [metadata] is the suite-level metadata for the test. | 179 /// [metadata] is the suite-level metadata for the test. |
| 180 Future<Suite> _loadBrowserFile(String path, TestPlatform platform, | 180 Future<Suite> _loadBrowserFile(String path, TestPlatform platform, |
| 181 Metadata metadata) async => | 181 Metadata metadata) async => |
| 182 (await _browserServer).loadSuite(path, platform, metadata); | 182 (await _browserServer).loadSuite(path, platform, metadata); |
| 183 | 183 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 }); | 262 }); |
| 263 | 263 |
| 264 try { | 264 try { |
| 265 var suite = new Suite((await completer.future).map((test) { | 265 var suite = new Suite((await completer.future).map((test) { |
| 266 var testMetadata = new Metadata.deserialize(test['metadata']); | 266 var testMetadata = new Metadata.deserialize(test['metadata']); |
| 267 return new IsolateTest(test['name'], testMetadata, test['sendPort']); | 267 return new IsolateTest(test['name'], testMetadata, test['sendPort']); |
| 268 }), | 268 }), |
| 269 metadata: metadata, | 269 metadata: metadata, |
| 270 path: path, | 270 path: path, |
| 271 platform: "VM", | 271 platform: TestPlatform.vm, |
| 272 os: currentOS, |
| 272 onClose: isolate.kill); | 273 onClose: isolate.kill); |
| 273 _suites.add(suite); | 274 _suites.add(suite); |
| 274 return suite; | 275 return suite; |
| 275 } finally { | 276 } finally { |
| 276 subscription.cancel(); | 277 subscription.cancel(); |
| 277 } | 278 } |
| 278 } | 279 } |
| 279 | 280 |
| 280 /// Closes the loader and releases all resources allocated by it. | 281 /// Closes the loader and releases all resources allocated by it. |
| 281 Future close() { | 282 Future close() { |
| 282 return _closeThunk.run(() async { | 283 return _closeThunk.run(() async { |
| 283 await Future.wait(_suites.map((suite) => suite.close())); | 284 await Future.wait(_suites.map((suite) => suite.close())); |
| 284 _suites.clear(); | 285 _suites.clear(); |
| 285 | 286 |
| 286 if (!_browserServerThunk.hasRun) return; | 287 if (!_browserServerThunk.hasRun) return; |
| 287 await (await _browserServer).close(); | 288 await (await _browserServer).close(); |
| 288 }); | 289 }); |
| 289 } | 290 } |
| 290 } | 291 } |
| OLD | NEW |