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 |
11 import 'package:analyzer/analyzer.dart'; | 11 import 'package:analyzer/analyzer.dart'; |
12 import 'package:async/async.dart'; | 12 import 'package:async/async.dart'; |
13 import 'package:path/path.dart' as p; | 13 import 'package:path/path.dart' as p; |
14 import 'package:stack_trace/stack_trace.dart'; | 14 import 'package:stack_trace/stack_trace.dart'; |
15 | 15 |
16 import '../backend/invoker.dart'; | 16 import '../backend/invoker.dart'; |
| 17 import '../backend/group.dart'; |
17 import '../backend/metadata.dart'; | 18 import '../backend/metadata.dart'; |
| 19 import '../backend/suite_entry.dart'; |
18 import '../backend/test_platform.dart'; | 20 import '../backend/test_platform.dart'; |
19 import '../util/dart.dart' as dart; | 21 import '../util/dart.dart' as dart; |
20 import '../util/io.dart'; | 22 import '../util/io.dart'; |
21 import '../util/remote_exception.dart'; | 23 import '../util/remote_exception.dart'; |
22 import '../utils.dart'; | 24 import '../utils.dart'; |
23 import 'browser/server.dart'; | 25 import 'browser/server.dart'; |
24 import 'configuration.dart'; | 26 import 'configuration.dart'; |
25 import 'hack_load_vm_file_hook.dart'; | 27 import 'hack_load_vm_file_hook.dart'; |
26 import 'load_exception.dart'; | 28 import 'load_exception.dart'; |
27 import 'load_suite.dart'; | 29 import 'load_suite.dart'; |
(...skipping 184 matching lines...) Loading... |
212 new LoadException(path, response["message"]), | 214 new LoadException(path, response["message"]), |
213 new Trace.current()); | 215 new Trace.current()); |
214 } else if (response["type"] == "error") { | 216 } else if (response["type"] == "error") { |
215 isolate.kill(); | 217 isolate.kill(); |
216 var asyncError = RemoteException.deserialize(response["error"]); | 218 var asyncError = RemoteException.deserialize(response["error"]); |
217 completer.completeError( | 219 completer.completeError( |
218 new LoadException(path, asyncError.error), | 220 new LoadException(path, asyncError.error), |
219 asyncError.stackTrace); | 221 asyncError.stackTrace); |
220 } else { | 222 } else { |
221 assert(response["type"] == "success"); | 223 assert(response["type"] == "success"); |
222 completer.complete(response["tests"]); | 224 completer.complete(response["entries"]); |
223 } | 225 } |
224 }); | 226 }); |
225 | 227 |
226 try { | 228 try { |
227 var suite = new RunnerSuite(const VMEnvironment(), | 229 var suite = new RunnerSuite( |
228 (await completer.future).map((test) { | 230 const VMEnvironment(), |
229 var testMetadata = new Metadata.deserialize(test['metadata']); | 231 _deserializeEntries(await completer.future), |
230 return new IsolateTest(test['name'], testMetadata, test['sendPort']); | |
231 }), | |
232 metadata: metadata, | 232 metadata: metadata, |
233 path: path, | 233 path: path, |
234 platform: TestPlatform.vm, | 234 platform: TestPlatform.vm, |
235 os: currentOS, | 235 os: currentOS, |
236 onClose: isolate.kill); | 236 onClose: isolate.kill); |
237 _suites.add(suite); | 237 _suites.add(suite); |
238 return suite; | 238 return suite; |
239 } finally { | 239 } finally { |
240 subscription.cancel(); | 240 subscription.cancel(); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
| 244 /// Deserializes [entries] into concrete [SuiteEntry] subclasses. |
| 245 Iterable<SuiteEntry> _deserializeEntries(List<Map> entries) { |
| 246 return entries.map((entry) { |
| 247 var metadata = new Metadata.deserialize(entry['metadata']); |
| 248 if (entry['type'] == 'group') { |
| 249 return new Group( |
| 250 entry['name'], metadata, _deserializeEntries(entry['entries'])); |
| 251 } else { |
| 252 return new IsolateTest(entry['name'], metadata, entry['sendPort']); |
| 253 } |
| 254 }); |
| 255 } |
| 256 |
244 /// Closes the loader and releases all resources allocated by it. | 257 /// Closes the loader and releases all resources allocated by it. |
245 Future close() { | 258 Future close() { |
246 return _closeMemo.runOnce(() async { | 259 return _closeMemo.runOnce(() async { |
247 await Future.wait(_suites.map((suite) => suite.close())); | 260 await Future.wait(_suites.map((suite) => suite.close())); |
248 _suites.clear(); | 261 _suites.clear(); |
249 | 262 |
250 if (!_browserServerMemo.hasRun) return; | 263 if (!_browserServerMemo.hasRun) return; |
251 await (await _browserServer).close(); | 264 await (await _browserServer).close(); |
252 }); | 265 }); |
253 } | 266 } |
254 } | 267 } |
OLD | NEW |