| 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.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 |
| 11 import 'package:path/path.dart' as p; | 11 import 'package:path/path.dart' as p; |
| 12 | 12 |
| 13 import 'dart.dart'; | 13 import '../backend/suite.dart'; |
| 14 import 'io.dart'; | 14 import '../util/dart.dart'; |
| 15 import '../util/io.dart'; |
| 16 import '../util/remote_exception.dart'; |
| 15 import 'isolate_test.dart'; | 17 import 'isolate_test.dart'; |
| 16 import 'load_exception.dart'; | 18 import 'load_exception.dart'; |
| 17 import 'remote_exception.dart'; | |
| 18 import 'suite.dart'; | |
| 19 | 19 |
| 20 /// A class for finding test files and loading them into a runnable form. | 20 /// A class for finding test files and loading them into a runnable form. |
| 21 class Loader { | 21 class Loader { |
| 22 /// The package root to use for loading tests, or `null` to use the automatic | 22 /// The package root to use for loading tests, or `null` to use the automatic |
| 23 /// root. | 23 /// root. |
| 24 final String _packageRoot; | 24 final String _packageRoot; |
| 25 | 25 |
| 26 /// All isolates that have been spun up by the loader. | 26 /// All isolates that have been spun up by the loader. |
| 27 final _isolates = new Set<Isolate>(); | 27 final _isolates = new Set<Isolate>(); |
| 28 | 28 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 58 var packageRoot = _packageRoot == null | 58 var packageRoot = _packageRoot == null |
| 59 ? p.join(p.dirname(path), 'packages') | 59 ? p.join(p.dirname(path), 'packages') |
| 60 : _packageRoot; | 60 : _packageRoot; |
| 61 | 61 |
| 62 if (!new Directory(packageRoot).existsSync()) { | 62 if (!new Directory(packageRoot).existsSync()) { |
| 63 throw new LoadException(path, "Directory $packageRoot does not exist."); | 63 throw new LoadException(path, "Directory $packageRoot does not exist."); |
| 64 } | 64 } |
| 65 | 65 |
| 66 var receivePort = new ReceivePort(); | 66 var receivePort = new ReceivePort(); |
| 67 return runInIsolate(''' | 67 return runInIsolate(''' |
| 68 import "package:unittest/src/vm_listener.dart"; | 68 import "package:unittest/src/runner/vm_listener.dart"; |
| 69 | 69 |
| 70 import "${p.toUri(p.absolute(path))}" as test; | 70 import "${p.toUri(p.absolute(path))}" as test; |
| 71 | 71 |
| 72 void main(_, Map message) { | 72 void main(_, Map message) { |
| 73 var sendPort = message['reply']; | 73 var sendPort = message['reply']; |
| 74 VmListener.start(sendPort, () => test.main); | 74 VmListener.start(sendPort, () => test.main); |
| 75 } | 75 } |
| 76 ''', { | 76 ''', { |
| 77 'reply': receivePort.sendPort | 77 'reply': receivePort.sendPort |
| 78 }, packageRoot: packageRoot).catchError((error, stackTrace) { | 78 }, packageRoot: packageRoot).catchError((error, stackTrace) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 /// Closes the loader and releases all resources allocated by it. | 100 /// Closes the loader and releases all resources allocated by it. |
| 101 Future close() { | 101 Future close() { |
| 102 for (var isolate in _isolates) { | 102 for (var isolate in _isolates) { |
| 103 isolate.kill(); | 103 isolate.kill(); |
| 104 } | 104 } |
| 105 _isolates.clear(); | 105 _isolates.clear(); |
| 106 return new Future.value(); | 106 return new Future.value(); |
| 107 } | 107 } |
| 108 } | 108 } |
| OLD | NEW |