Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: lib/src/loader.dart

Issue 933083002: Add a test runner executable. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/load_exception.dart ('k') | lib/src/remote_exception.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/loader.dart
diff --git a/lib/src/loader.dart b/lib/src/loader.dart
index e5b843c503d38044ca725ecdcbf9226858a4fb0b..2df9bfd19536aef42ce87f5f0f0ee92d74e50060 100644
--- a/lib/src/loader.dart
+++ b/lib/src/loader.dart
@@ -12,6 +12,8 @@ import 'package:path/path.dart' as p;
import 'dart.dart';
import 'isolate_test.dart';
+import 'load_exception.dart';
+import 'remote_exception.dart';
import 'suite.dart';
/// A class for finding test files and loading them into a runnable form.
@@ -49,9 +51,7 @@ class Loader {
/// Loads a test suite from the file at [path].
///
- /// This wil throw a [FileSystemException] if there's no `packages/` directory
- /// available for [path]. Any other load error will cause an
- /// [IsolateSpawnException] or a [RemoteException].
+ /// This will throw a [LoadException] if the file fails to load.
Future<Suite> loadFile(String path) {
// TODO(nweiz): Support browser tests.
var packageRoot = _packageRoot == null
@@ -59,7 +59,7 @@ class Loader {
: _packageRoot;
if (!new Directory(packageRoot).existsSync()) {
- throw new FileSystemException("Directory $packageRoot does not exist.");
+ throw new LoadException(path, "Directory $packageRoot does not exist.");
}
var receivePort = new ReceivePort();
@@ -70,15 +70,27 @@ import "${p.toUri(p.absolute(path))}" as test;
void main(_, Map message) {
var sendPort = message['reply'];
- VmListener.start(sendPort, test.main);
+ VmListener.start(sendPort, () => test.main);
}
''', {
'reply': receivePort.sendPort
- }, packageRoot: packageRoot).then((isolate) {
+ }, packageRoot: packageRoot).catchError((error, stackTrace) {
+ receivePort.close();
+ return new Future.error(new LoadException(path, error), stackTrace);
+ }).then((isolate) {
_isolates.add(isolate);
return receivePort.first;
- }).then((tests) {
- return new Suite(path, tests.map((test) {
+ }).then((response) {
+ if (response["type"] == "loadException") {
+ return new Future.error(new LoadException(path, response["message"]));
+ } else if (response["type"] == "error") {
+ var asyncError = RemoteException.deserialize(response["error"]);
+ return new Future.error(
+ new LoadException(path, asyncError.error),
+ asyncError.stackTrace);
+ }
+
+ return new Suite(path, response["tests"].map((test) {
return new IsolateTest(test['name'], test['sendPort']);
}));
});
« no previous file with comments | « lib/src/load_exception.dart ('k') | lib/src/remote_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698