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

Side by Side Diff: runtime/observatory/tests/service/test_helper.dart

Issue 1241683005: Support piping log data over the service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « runtime/observatory/tests/service/logging_test.dart ('k') | runtime/vm/bootstrap_natives.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override --checked 4 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override --checked
5 5
6 library test_helper; 6 library test_helper;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 subscription.cancel(); 230 subscription.cancel();
231 completer.complete(); 231 completer.complete();
232 } 232 }
233 }); 233 });
234 }); 234 });
235 isolate.resume(); 235 isolate.resume();
236 return completer.future; 236 return completer.future;
237 } 237 }
238 238
239 239
240 Future resumeAndAwaitEvent(Isolate isolate, stream, onEvent) async {
241 Completer completer = new Completer();
242 var sub;
243 sub = await isolate.vm.listenEventStream(
244 stream,
245 (ServiceEvent event) {
246 var r = onEvent(event);
247 if (r is! Future) {
248 r = new Future.value(r);
249 }
250 r.then((x) => sub.cancel().then((_) {
251 completer.complete();
252 }));
253 });
254 await isolate.resume();
255 return completer.future;
256 }
257
258 IsolateTest resumeIsolateAndAwaitEvent(stream, onEvent) {
259 return (Isolate isolate) async =>
260 resumeAndAwaitEvent(isolate, stream, onEvent);
261 }
262
263
240 Future<Class> getClassFromRootLib(Isolate isolate, String className) async { 264 Future<Class> getClassFromRootLib(Isolate isolate, String className) async {
241 Library rootLib = await isolate.rootLibrary.load(); 265 Library rootLib = await isolate.rootLibrary.load();
242 for (var i = 0; i < rootLib.classes.length; i++) { 266 for (var i = 0; i < rootLib.classes.length; i++) {
243 Class cls = rootLib.classes[i]; 267 Class cls = rootLib.classes[i];
244 if (cls.name == className) { 268 if (cls.name == className) {
245 return cls; 269 return cls;
246 } 270 }
247 } 271 }
248 return null; 272 return null;
249 } 273 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 }, onError: (e, st) { 312 }, onError: (e, st) {
289 process.requestExit(); 313 process.requestExit();
290 if (!_isWebSocketDisconnect(e)) { 314 if (!_isWebSocketDisconnect(e)) {
291 print('Unexpected exception in service tests: $e $st'); 315 print('Unexpected exception in service tests: $e $st');
292 throw e; 316 throw e;
293 } 317 }
294 }); 318 });
295 }); 319 });
296 } 320 }
297 } 321 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/logging_test.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698