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

Unified Diff: pkg/scheduled_test/test/metatest.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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
Index: pkg/scheduled_test/test/metatest.dart
diff --git a/pkg/scheduled_test/test/metatest.dart b/pkg/scheduled_test/test/metatest.dart
index 9e94d07ff91dfc76ac31fc09d3ca4b6916a60858..e846773642bb63606c79db7bf37381a8633b5ee1 100644
--- a/pkg/scheduled_test/test/metatest.dart
+++ b/pkg/scheduled_test/test/metatest.dart
@@ -107,40 +107,47 @@ SendPort _replyTo;
/// The cached [Future] for [_inChildIsolate].
Future<bool> _inChildIsolateFuture;
+/// The initial message received by the isolate.
+var _initialMessage;
+
+void metaTestInit(message) {
+ _initialMessage = message;
+}
+
/// Returns whether or not we're running in a child isolate that's supposed to
/// run a test.
Future<bool> get _inChildIsolate {
if (_inChildIsolateFuture != null) return _inChildIsolateFuture;
- var completer = new Completer();
- port.receive((message, replyTo) {
- _testToRun = message['testToRun'];
- _executable = message['executable'];
- _replyTo = replyTo;
- port.close();
- completer.complete(true);
- });
-
- // TODO(nweiz): don't use a timeout here once issue 8416 is fixed.
- _inChildIsolateFuture = timeout(completer.future, 500, () {
- port.close();
- return false;
- });
+ if (_initialMessage == null) {
+ _inChildIsolateFuture = new Future.value(false);
+ } else {
+ _testToRun = _initialMessage['testToRun'];
+ _executable = _initialMessage['executable'];
+ _replyTo = _initialMessage['replyTo'];
+ _inChildIsolateFuture = new Future.value(true);
+ }
return _inChildIsolateFuture;
}
/// Runs the test described by [description] in its own isolate. Returns a map
/// describing the results of that test run.
Future<Map> _runInIsolate(String description) {
+ var replyPort = new ReceivePort();
// TODO(nweiz): Don't use path here once issue 8440 is fixed.
- var future = spawnUri(path.join(path.current, Platform.script)).call({
+ return Isolate.spawnUri(Uri.parse(path.join(path.current, Platform.script)),
+ [], {
'testToRun': description,
- 'executable': Platform.executable
- });
- // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can
- // capture top-level exceptions.
- return timeout(future, 30 * 1000, () {
- throw 'Timed out waiting for test to complete.';
+ 'executable': Platform.executable,
+ 'replyTo': replyPort.sendPort
+ }).then((_) {
+ var future = replyPort.first;
+
+ // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can
+ // capture top-level exceptions.
+ return timeout(future, 30 * 1000, () {
+ throw 'Timed out waiting for test to complete.';
+ });
});
}
« no previous file with comments | « pkg/scheduled_test/test/descriptor/pattern_test.dart ('k') | pkg/scheduled_test/test/scheduled_future_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698