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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/vmservice/client/test/allocations_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/client/test/test_helper.dart
===================================================================
--- runtime/bin/vmservice/client/test/test_helper.dart (revision 0)
+++ runtime/bin/vmservice/client/test/test_helper.dart (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test_helper;
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+
+class TestLauncher {
+ final String script;
+ Process process;
+
+ TestLauncher(this.script);
+
+ String get scriptPath {
+ var dartScript = Platform.script.toFilePath();
+ var splitPoint = dartScript.lastIndexOf(Platform.pathSeparator);
+ var scriptDirectory = dartScript.substring(0, splitPoint);
+ return scriptDirectory + Platform.pathSeparator + script;
+ }
+
+ Future<int> launch() {
+ String dartExecutable = Platform.executable;
+ print('** Launching $scriptPath');
+ return Process.start(dartExecutable,
+ ['--enable-vm-service:0', scriptPath]).then((p) {
+
+ Completer completer = new Completer();
+ process = p;
+ var portNumber;
+ var blank;
+ var first = true;
+ process.stdout.transform(UTF8.decoder)
+ .transform(new LineSplitter()).listen((line) {
+ if (line.startsWith('Observatory listening on http://')) {
+ RegExp portExp = new RegExp(r"\d+.\d+.\d+.\d+:(\d+)");
+ var port = portExp.firstMatch(line).group(1);
+ portNumber = int.parse(port);
+ }
+ if (line == '') {
+ // Received blank line.
+ blank = true;
+ }
+ if (portNumber != null && blank == true && first == true) {
+ completer.complete(portNumber);
+ // Stop repeat completions.
+ first = false;
+ print('** Signaled to run test queries on $portNumber');
+ }
+ print(line);
+ });
+ process.stderr.transform(UTF8.decoder)
+ .transform(new LineSplitter()).listen((line) {
+ print(line);
+ });
+ process.exitCode.then((code) {
+ //Expect.equals(0, code, 'Launched dart executable exited with error.');
+ });
+ return completer.future;
+ });
+ }
+
+ void requestExit() {
+ print('** Requesting script to exit.');
+ process.stdin.add([32, 13, 10]);
+ }
+}
+
« 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