| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 /// Unlike [pubServe], this doesn't determine the port number of the server, and | 148 /// Unlike [pubServe], this doesn't determine the port number of the server, and |
| 149 /// so may be used to test for errors in the initialization process. | 149 /// so may be used to test for errors in the initialization process. |
| 150 /// | 150 /// |
| 151 /// Returns the `pub serve` process. | 151 /// Returns the `pub serve` process. |
| 152 ScheduledProcess startPubServe({Iterable<String> args, | 152 ScheduledProcess startPubServe({Iterable<String> args, |
| 153 bool createWebDir: true}) { | 153 bool createWebDir: true}) { |
| 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 "--log-admin-url" | 159 "--log-admin-url" |
| 159 ]; | 160 ]; |
| 160 | 161 |
| 161 if (args != null) pubArgs.addAll(args); | 162 if (args != null) pubArgs.addAll(args); |
| 162 | 163 |
| 163 // Dart2js can take a long time to compile dart code, so we increase the | 164 // Dart2js can take a long time to compile dart code, so we increase the |
| 164 // timeout to cope with that. | 165 // timeout to cope with that. |
| 165 currentSchedule.timeout *= 1.5; | 166 currentSchedule.timeout *= 1.5; |
| 166 | 167 |
| 167 if (createWebDir) d.dir(appPath, [d.dir("web")]).create(); | 168 if (createWebDir) d.dir(appPath, [d.dir("web")]).create(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return _pubServer; | 217 return _pubServer; |
| 217 } | 218 } |
| 218 | 219 |
| 219 /// The regular expression for parsing pub's output line describing the URL for | 220 /// The regular expression for parsing pub's output line describing the URL for |
| 220 /// the server. | 221 /// the server. |
| 221 final _parsePortRegExp = new RegExp(r"([^ ]+) +on http://localhost:(\d+)"); | 222 final _parsePortRegExp = new RegExp(r"([^ ]+) +on http://localhost:(\d+)"); |
| 222 | 223 |
| 223 /// Parses the port number from the "Running admin server on localhost:1234" | 224 /// Parses the port number from the "Running admin server on localhost:1234" |
| 224 /// line printed by pub serve. | 225 /// line printed by pub serve. |
| 225 bool _parseAdminPort(String line) { | 226 bool _parseAdminPort(String line) { |
| 227 expect(line, startsWith('Running admin server on')); |
| 226 var match = _parsePortRegExp.firstMatch(line); | 228 var match = _parsePortRegExp.firstMatch(line); |
| 227 if (match == null) return false; | 229 if (match == null) return false; |
| 228 _adminPort = int.parse(match[2]); | 230 _adminPort = int.parse(match[2]); |
| 229 return true; | 231 return true; |
| 230 } | 232 } |
| 231 | 233 |
| 232 /// Parses the port number from the "Serving blah on localhost:1234" line | 234 /// Parses the port number from the "Serving blah on localhost:1234" line |
| 233 /// printed by pub serve. | 235 /// printed by pub serve. |
| 234 bool _parsePort(String line) { | 236 bool _parsePort(String line) { |
| 235 var match = _parsePortRegExp.firstMatch(line); | 237 var match = _parsePortRegExp.firstMatch(line); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 /// included. Unlike [getServerUrl], this should only be called after the ports | 493 /// included. Unlike [getServerUrl], this should only be called after the ports |
| 492 /// are known. | 494 /// are known. |
| 493 String _getServerUrlSync([String root, String path]) { | 495 String _getServerUrlSync([String root, String path]) { |
| 494 if (root == null) root = 'web'; | 496 if (root == null) root = 'web'; |
| 495 expect(_ports, contains(root)); | 497 expect(_ports, contains(root)); |
| 496 var url = "http://localhost:${_ports[root]}"; | 498 var url = "http://localhost:${_ports[root]}"; |
| 497 if (path != null) url = "$url/$path"; | 499 if (path != null) url = "$url/$path"; |
| 498 return url; | 500 return url; |
| 499 } | 501 } |
| 500 | 502 |
| OLD | NEW |