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

Side by Side Diff: runtime/bin/vmservice/client/test/test_helper.dart

Issue 445023003: Move service library test into observatory package. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test_helper;
6
7 import 'dart:async';
8 import 'dart:convert';
9 import 'dart:io';
10
11 class TestLauncher {
12 final String script;
13 Process process;
14
15 TestLauncher(this.script);
16
17 String get scriptPath {
18 var dartScript = Platform.script.toFilePath();
19 var splitPoint = dartScript.lastIndexOf(Platform.pathSeparator);
20 var scriptDirectory = dartScript.substring(0, splitPoint);
21 return scriptDirectory + Platform.pathSeparator + script;
22 }
23
24 Future<int> launch() {
25 String dartExecutable = Platform.executable;
26 print('** Launching $scriptPath');
27 return Process.start(dartExecutable,
28 ['--enable-vm-service:0', scriptPath]).then((p) {
29
30 Completer completer = new Completer();
31 process = p;
32 var portNumber;
33 var blank;
34 var first = true;
35 process.stdout.transform(UTF8.decoder)
36 .transform(new LineSplitter()).listen((line) {
37 if (line.startsWith('Observatory listening on http://')) {
38 RegExp portExp = new RegExp(r"\d+.\d+.\d+.\d+:(\d+)");
39 var port = portExp.firstMatch(line).group(1);
40 portNumber = int.parse(port);
41 }
42 if (line == '') {
43 // Received blank line.
44 blank = true;
45 }
46 if (portNumber != null && blank == true && first == true) {
47 completer.complete(portNumber);
48 // Stop repeat completions.
49 first = false;
50 print('** Signaled to run test queries on $portNumber');
51 }
52 print(line);
53 });
54 process.stderr.transform(UTF8.decoder)
55 .transform(new LineSplitter()).listen((line) {
56 print(line);
57 });
58 process.exitCode.then((code) {
59 //Expect.equals(0, code, 'Launched dart executable exited with error.');
60 });
61 return completer.future;
62 });
63 }
64
65 void requestExit() {
66 print('** Requesting script to exit.');
67 process.stdin.add([32, 13, 10]);
68 }
69 }
70
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/test/allocations_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698