 Chromium Code Reviews
 Chromium Code Reviews Issue 27215002:
  Very simple version of Isolates.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 27215002:
  Very simple version of Isolates.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| 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..257f4bdbb44657d8399b6a97b9263902d02c3235 100644 | 
| --- a/pkg/scheduled_test/test/metatest.dart | 
| +++ b/pkg/scheduled_test/test/metatest.dart | 
| @@ -107,40 +107,43 @@ SendPort _replyTo; | 
| /// The cached [Future] for [_inChildIsolate]. | 
| Future<bool> _inChildIsolateFuture; | 
| +/// The initial message the isolate received. | 
| 
Lasse Reichstein Nielsen
2013/10/25 09:42:49
the isolate received -> received by the isolate.
 
floitsch
2013/10/25 13:11:01
Done.
 | 
| +var initialMessage; | 
| + | 
| /// 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.'; | 
| + }); | 
| }); | 
| } |