| OLD | NEW |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 /// | 99 /// |
| 100 /// Returns the `pub serve` process. | 100 /// Returns the `pub serve` process. |
| 101 ScheduledProcess startPubServe([Iterable<String> args]) { | 101 ScheduledProcess startPubServe([Iterable<String> args]) { |
| 102 // Use port 0 to get an ephemeral port. | 102 // Use port 0 to get an ephemeral port. |
| 103 var pubArgs = ["serve", "--port=0", "--hostname=127.0.0.1", "--force-poll"]; | 103 var pubArgs = ["serve", "--port=0", "--hostname=127.0.0.1", "--force-poll"]; |
| 104 | 104 |
| 105 if (args != null) pubArgs.addAll(args); | 105 if (args != null) pubArgs.addAll(args); |
| 106 | 106 |
| 107 // Dart2js can take a long time to compile dart code, so we increase the | 107 // Dart2js can take a long time to compile dart code, so we increase the |
| 108 // timeout to cope with that. | 108 // timeout to cope with that. |
| 109 currentSchedule.timeout = new Duration(seconds: 15); | 109 currentSchedule.timeout *= 1.5; |
| 110 | 110 |
| 111 return startPub(args: pubArgs); | 111 return startPub(args: pubArgs); |
| 112 } | 112 } |
| 113 | 113 |
| 114 /// Schedules starting the "pub serve" process and records its port number for | 114 /// Schedules starting the "pub serve" process and records its port number for |
| 115 /// future requests. | 115 /// future requests. |
| 116 /// | 116 /// |
| 117 /// If [shouldGetFirst] is `true`, validates that pub get is run first. In that | 117 /// If [shouldGetFirst] is `true`, validates that pub get is run first. In that |
| 118 /// case, you can also pass [numDownloads] to specify how many packages should | 118 /// case, you can also pass [numDownloads] to specify how many packages should |
| 119 /// be downloaded during the get. | 119 /// be downloaded during the get. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 /// socket. It omitted, request is JSON encoded to a string first. | 240 /// socket. It omitted, request is JSON encoded to a string first. |
| 241 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { | 241 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { |
| 242 schedule(() => _ensureWebSocket().then((_) { | 242 schedule(() => _ensureWebSocket().then((_) { |
| 243 if (encodeRequest) request = JSON.encode(request); | 243 if (encodeRequest) request = JSON.encode(request); |
| 244 _webSocket.add(request); | 244 _webSocket.add(request); |
| 245 return _webSocketBroadcastStream.first.then((value) { | 245 return _webSocketBroadcastStream.first.then((value) { |
| 246 expect(JSON.decode(value), expectation); | 246 expect(JSON.decode(value), expectation); |
| 247 }); | 247 }); |
| 248 }), "send $request to web socket and expect reply that $expectation"); | 248 }), "send $request to web socket and expect reply that $expectation"); |
| 249 } | 249 } |
| OLD | NEW |