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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 return Future.wait(_platforms.map((platform) { | 112 return Future.wait(_platforms.map((platform) { |
113 return new Future.sync(() { | 113 return new Future.sync(() { |
114 if (!metadata.testOn.evaluate(platform, os: currentOS)) return null; | 114 if (!metadata.testOn.evaluate(platform, os: currentOS)) return null; |
115 | 115 |
116 if (_pubServeUrl != null && !p.isWithin('test', path)) { | 116 if (_pubServeUrl != null && !p.isWithin('test', path)) { |
117 throw new LoadException(path, | 117 throw new LoadException(path, |
118 'When using "pub serve", all test files must be in test/.'); | 118 'When using "pub serve", all test files must be in test/.'); |
119 } | 119 } |
120 | 120 |
121 if (platform == TestPlatform.chrome) return _loadBrowserFile(path); | 121 if (platform.isBrowser) return _loadBrowserFile(path, platform); |
122 assert(platform == TestPlatform.vm); | 122 assert(platform == TestPlatform.vm); |
123 return _loadVmFile(path); | 123 return _loadVmFile(path); |
124 }).then((suite) { | 124 }).then((suite) { |
125 if (suite == null) return null; | 125 if (suite == null) return null; |
126 return suite.change(metadata: metadata).filter(platform, os: currentOS); | 126 return suite.change(metadata: metadata).filter(platform, os: currentOS); |
127 }); | 127 }); |
128 })).then((suites) => suites.where((suite) => suite != null).toList()); | 128 })).then((suites) => suites.where((suite) => suite != null).toList()); |
129 } | 129 } |
130 | 130 |
131 /// Load the test suite at [path] in a browser. | 131 /// Load the test suite at [path] in a browser. |
132 Future<Suite> _loadBrowserFile(String path) => | 132 Future<Suite> _loadBrowserFile(String path, TestPlatform platform) => |
133 _browserServer.then((browserServer) => browserServer.loadSuite(path)); | 133 _browserServer.then((browserServer) => |
| 134 browserServer.loadSuite(path, platform)); |
134 | 135 |
135 /// Load the test suite at [path] in VM isolate. | 136 /// Load the test suite at [path] in VM isolate. |
136 Future<Suite> _loadVmFile(String path) { | 137 Future<Suite> _loadVmFile(String path) { |
137 var packageRoot = packageRootFor(path, _packageRoot); | 138 var packageRoot = packageRootFor(path, _packageRoot); |
138 var receivePort = new ReceivePort(); | 139 var receivePort = new ReceivePort(); |
139 | 140 |
140 return new Future.sync(() { | 141 return new Future.sync(() { |
141 if (_pubServeUrl != null) { | 142 if (_pubServeUrl != null) { |
142 var url = _pubServeUrl.resolve( | 143 var url = _pubServeUrl.resolve( |
143 p.withoutExtension(p.relative(path, from: 'test')) + | 144 p.withoutExtension(p.relative(path, from: 'test')) + |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 Future close() { | 202 Future close() { |
202 for (var isolate in _isolates) { | 203 for (var isolate in _isolates) { |
203 isolate.kill(); | 204 isolate.kill(); |
204 } | 205 } |
205 _isolates.clear(); | 206 _isolates.clear(); |
206 | 207 |
207 if (_browserServerCompleter == null) return new Future.value(); | 208 if (_browserServerCompleter == null) return new Future.value(); |
208 return _browserServer.then((browserServer) => browserServer.close()); | 209 return _browserServer.then((browserServer) => browserServer.close()); |
209 } | 210 } |
210 } | 211 } |
OLD | NEW |