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

Side by Side Diff: lib/src/isolate_test.dart

Issue 914963003: Add a VmListener and IsolateTest class for running tests in other isolates. (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 unified diff | Download patch
« no previous file with comments | « .status ('k') | lib/src/live_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library unittest.isolate_test;
6
7 import 'dart:isolate';
8
9 import 'live_test.dart';
10 import 'live_test_controller.dart';
11 import 'remote_exception.dart';
12 import 'state.dart';
13 import 'suite.dart';
14 import 'test.dart';
15
16 /// A test in another isolate.
17 class IsolateTest implements Test {
18 final String name;
19
20 /// The port on which to communicate with the remote test.
21 final SendPort _sendPort;
22
23 IsolateTest(this.name, this._sendPort);
24
25 /// Loads a single runnable instance of this test.
26 LiveTest load(Suite suite) {
27 var receivePort;
28 var controller;
29 controller = new LiveTestController(suite, this, () {
30 controller.setState(const State(Status.running, Result.success));
31
32 receivePort = new ReceivePort();
33 _sendPort.send({
34 'command': 'run',
35 'reply': receivePort.sendPort
36 });
37
38 receivePort.listen((message) {
39 if (message['type'] == 'error') {
40 var asyncError = RemoteException.deserialize(message['error']);
41 controller.addError(asyncError.error, asyncError.stackTrace);
42 } else if (message['type'] == 'state-change') {
43 controller.setState(
44 new State(
45 new Status.parse(message['status']),
46 new Result.parse(message['result'])));
47 } else {
48 assert(message['type'] == 'complete');
49 controller.completer.complete();
50 }
51 });
52 }, onClose: () {
53 if (receivePort != null) receivePort.close();
54 });
55 return controller.liveTest;
56 }
57 }
OLDNEW
« no previous file with comments | « .status ('k') | lib/src/live_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698