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

Side by Side Diff: test/serve/utils.dart

Issue 1215833002: Use the new test runner. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 4
5 library pub_tests; 5 library pub_tests;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 var pubArgs = [ 154 var pubArgs = [
155 "serve", 155 "serve",
156 "--port=0", // Use port 0 to get an ephemeral port. 156 "--port=0", // Use port 0 to get an ephemeral port.
157 "--force-poll", 157 "--force-poll",
158 "--admin-port=0", // Use port 0 to get an ephemeral port. 158 "--admin-port=0", // Use port 0 to get an ephemeral port.
159 "--log-admin-url" 159 "--log-admin-url"
160 ]; 160 ];
161 161
162 if (args != null) pubArgs.addAll(args); 162 if (args != null) pubArgs.addAll(args);
163 163
164 // Dart2js can take a long time to compile dart code, so we increase the
165 // timeout to cope with that.
166 currentSchedule.timeout *= 1.5;
167
168 if (createWebDir) d.dir(appPath, [d.dir("web")]).create(); 164 if (createWebDir) d.dir(appPath, [d.dir("web")]).create();
169 return startPub(args: pubArgs); 165 return startPub(args: pubArgs);
170 } 166 }
171 167
172 /// Schedules starting the "pub serve" process and records its port number for 168 /// Schedules starting the "pub serve" process and records its port number for
173 /// future requests. 169 /// future requests.
174 /// 170 ///
175 /// If [shouldGetFirst] is `true`, validates that pub get is run first. 171 /// If [shouldGetFirst] is `true`, validates that pub get is run first.
176 /// 172 ///
177 /// If [createWebDir] is `true`, creates a `web/` directory if one doesn't exist 173 /// If [createWebDir] is `true`, creates a `web/` directory if one doesn't exist
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 /// It returns the response as a [Future]. 360 /// It returns the response as a [Future].
365 Future<Map> webSocketRequest(String method, [Map params]) { 361 Future<Map> webSocketRequest(String method, [Map params]) {
366 var completer = new Completer(); 362 var completer = new Completer();
367 schedule(() { 363 schedule(() {
368 return Future.wait([ 364 return Future.wait([
369 _ensureWebSocket(), 365 _ensureWebSocket(),
370 awaitObject(params), 366 awaitObject(params),
371 ]).then((results) { 367 ]).then((results) {
372 var resolvedParams = results[1]; 368 var resolvedParams = results[1];
373 chainToCompleter( 369 chainToCompleter(
374 currentSchedule.wrapFuture(_jsonRpcRequest(method, resolvedParams)), 370 _jsonRpcRequest(method, resolvedParams),
375 completer); 371 completer);
376 }); 372 });
377 }, "send $method with $params to web socket"); 373 }, "send $method with $params to web socket");
378 return completer.future; 374 return completer.future;
379 } 375 }
380 376
381 /// Sends a JSON RPC 2.0 request to the running pub serve's web socket 377 /// Sends a JSON RPC 2.0 request to the running pub serve's web socket
382 /// connection, waits for a reply, then verifies the result. 378 /// connection, waits for a reply, then verifies the result.
383 /// 379 ///
384 /// This calls a method named [method] with the given [params]. [params] may 380 /// This calls a method named [method] with the given [params]. [params] may
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 /// included. Unlike [getServerUrl], this should only be called after the ports 489 /// included. Unlike [getServerUrl], this should only be called after the ports
494 /// are known. 490 /// are known.
495 String _getServerUrlSync([String root, String path]) { 491 String _getServerUrlSync([String root, String path]) {
496 if (root == null) root = 'web'; 492 if (root == null) root = 'web';
497 expect(_ports, contains(root)); 493 expect(_ports, contains(root));
498 var url = "http://localhost:${_ports[root]}"; 494 var url = "http://localhost:${_ports[root]}";
499 if (path != null) url = "$url/$path"; 495 if (path != null) url = "$url/$path";
500 return url; 496 return url;
501 } 497 }
502 498
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698