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

Side by Side Diff: lib/src/runner/vm/isolate_listener.dart

Issue 1107743002: Support asynchronous main methods. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/iframe_listener.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.vm.isolate_listener; 5 library test.runner.vm.isolate_listener;
6 6
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import '../../backend/declarer.dart'; 10 import '../../backend/declarer.dart';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (main is! Function) { 44 if (main is! Function) {
45 _sendLoadException(sendPort, "Top-level main getter is not a function."); 45 _sendLoadException(sendPort, "Top-level main getter is not a function.");
46 return; 46 return;
47 } else if (main is! AsyncFunction) { 47 } else if (main is! AsyncFunction) {
48 _sendLoadException( 48 _sendLoadException(
49 sendPort, "Top-level main() function takes arguments."); 49 sendPort, "Top-level main() function takes arguments.");
50 return; 50 return;
51 } 51 }
52 52
53 var declarer = new Declarer(); 53 var declarer = new Declarer();
54 try { 54 runZoned(() => new Future.sync(main), zoneValues: {
55 runZoned(main, zoneValues: {#test.declarer: declarer}); 55 #test.declarer: declarer
56 } catch (error, stackTrace) { 56 }).then((_) {
57 var suite = new Suite(declarer.tests, metadata: metadata)
58 .forPlatform(TestPlatform.vm, os: currentOS);
59 new IsolateListener._(suite)._listen(sendPort);
60 }, onError: (error, stackTrace) {
57 sendPort.send({ 61 sendPort.send({
58 "type": "error", 62 "type": "error",
59 "error": RemoteException.serialize(error, stackTrace) 63 "error": RemoteException.serialize(error, stackTrace)
60 }); 64 });
61 return; 65 });
62 }
63
64 var suite = new Suite(declarer.tests, metadata: metadata)
65 .forPlatform(TestPlatform.vm, os: currentOS);
66 new IsolateListener._(suite)._listen(sendPort);
67 } 66 }
68 67
69 /// Sends a message over [sendPort] indicating that the tests failed to load. 68 /// Sends a message over [sendPort] indicating that the tests failed to load.
70 /// 69 ///
71 /// [message] should describe the failure. 70 /// [message] should describe the failure.
72 static void _sendLoadException(SendPort sendPort, String message) { 71 static void _sendLoadException(SendPort sendPort, String message) {
73 sendPort.send({"type": "loadException", "message": message}); 72 sendPort.send({"type": "loadException", "message": message});
74 } 73 }
75 74
76 IsolateListener._(this._suite); 75 IsolateListener._(this._suite);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 asyncError.error, asyncError.stackTrace) 127 asyncError.error, asyncError.stackTrace)
129 }); 128 });
130 }); 129 });
131 130
132 liveTest.onPrint.listen((line) => 131 liveTest.onPrint.listen((line) =>
133 sendPort.send({"type": "print", "line": line})); 132 sendPort.send({"type": "print", "line": line}));
134 133
135 liveTest.run().then((_) => sendPort.send({"type": "complete"})); 134 liveTest.run().then((_) => sendPort.send({"type": "complete"}));
136 } 135 }
137 } 136 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/iframe_listener.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698