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

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

Issue 1685363002: Add a platform plugin infrastructure. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 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 | « lib/src/runner/vm/isolate_listener.dart ('k') | lib/src/runner/vm/platform.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 import 'dart:async';
6 import 'dart:isolate';
7
8 import '../../backend/group.dart';
9 import '../../backend/live_test.dart';
10 import '../../backend/live_test_controller.dart';
11 import '../../backend/metadata.dart';
12 import '../../backend/operating_system.dart';
13 import '../../backend/state.dart';
14 import '../../backend/suite.dart';
15 import '../../backend/test.dart';
16 import '../../backend/test_platform.dart';
17 import '../../util/remote_exception.dart';
18 import '../../utils.dart';
19
20 /// A test in another isolate.
21 class IsolateTest extends Test {
22 final String name;
23 final Metadata metadata;
24
25 /// The port on which to communicate with the remote test.
26 final SendPort _sendPort;
27
28 IsolateTest(this.name, this.metadata, this._sendPort);
29
30 LiveTest load(Suite suite, {Iterable<Group> groups}) {
31 var controller;
32
33 // We get a new send port for communicating with the live test, since
34 // [_sendPort] is only for communicating with the non-live test. This will
35 // be non-null once the test starts running.
36 var sendPortCompleter;
37
38 var receivePort;
39 controller = new LiveTestController(suite, this, () {
40 controller.setState(const State(Status.running, Result.success));
41
42 sendPortCompleter = new Completer();
43 receivePort = new ReceivePort();
44 _sendPort.send({
45 'command': 'run',
46 'reply': receivePort.sendPort
47 });
48
49 receivePort.listen((message) {
50 if (message['type'] == 'started') {
51 sendPortCompleter.complete(message['reply']);
52 } else if (message['type'] == 'error') {
53 var asyncError = RemoteException.deserialize(message['error']);
54 controller.addError(asyncError.error, asyncError.stackTrace);
55 } else if (message['type'] == 'state-change') {
56 controller.setState(
57 new State(
58 new Status.parse(message['status']),
59 new Result.parse(message['result'])));
60 } else if (message['type'] == 'print') {
61 controller.print(message['line']);
62 } else {
63 assert(message['type'] == 'complete');
64 controller.completer.complete();
65 }
66 });
67 }, () {
68 // If the test has finished running, just disconnect the receive port. The
69 // Dart process won't terminate if there are any live receive ports open.
70 if (controller.completer.isCompleted) {
71 receivePort.close();
72 return;
73 }
74
75 invoke(() async {
76 // If the test is still running, send it a message telling it to shut
77 // down ASAP. This causes the [Invoker] to eagerly throw exceptions
78 // whenever the test touches it.
79 var sendPort = await sendPortCompleter.future;
80 sendPort.send({'command': 'close'});
81 await controller.completer.future;
82 receivePort.close();
83 });
84 }, groups: groups);
85 return controller.liveTest;
86 }
87
88 Test forPlatform(TestPlatform platform, {OperatingSystem os}) {
89 if (!metadata.testOn.evaluate(platform, os: os)) return null;
90 return new IsolateTest(
91 name, metadata.forPlatform(platform, os: os), _sendPort);
92 }
93 }
OLDNEW
« no previous file with comments | « lib/src/runner/vm/isolate_listener.dart ('k') | lib/src/runner/vm/platform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698