| Index: sdk/lib/_internal/pub/test/test_pub.dart
|
| diff --git a/sdk/lib/_internal/pub/test/test_pub.dart b/sdk/lib/_internal/pub/test/test_pub.dart
|
| index f1b66b7a8995487be4ec80d2be9a84af09acd1db..5d1afcfd17fb1b7ca35ac96e14068d3dde17a381 100644
|
| --- a/sdk/lib/_internal/pub/test/test_pub.dart
|
| +++ b/sdk/lib/_internal/pub/test/test_pub.dart
|
| @@ -91,6 +91,8 @@ Future<List<String>> getRequestedPaths() {
|
| void serve([List<d.Descriptor> contents]) {
|
| var baseDir = d.dir("serve-dir", contents);
|
|
|
| + _hasServer = true;
|
| +
|
| schedule(() {
|
| return _closeServer().then((_) {
|
| return SafeHttpServer.bind("localhost", 0).then((server) {
|
| @@ -144,6 +146,9 @@ Future _closeServer() {
|
| return sleep(10);
|
| }
|
|
|
| +/// `true` if the current test spins up an HTTP server.
|
| +bool _hasServer = false;
|
| +
|
| /// The [d.DirectoryDescriptor] describing the server layout of `/api/packages`
|
| /// on the test server.
|
| ///
|
| @@ -458,6 +463,16 @@ ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
|
| environment['_PUB_TEST_TOKEN_ENDPOINT'] =
|
| tokenEndpoint.toString();
|
| }
|
| +
|
| + // If there is a server running, tell pub what its URL is so hosted
|
| + // dependencies will look there.
|
| + if (_hasServer) {
|
| + return port.then((p) {
|
| + environment['PUB_HOSTED_URL'] = "http://localhost:$p";
|
| + return environment;
|
| + });
|
| + }
|
| +
|
| return environment;
|
| });
|
|
|
| @@ -609,8 +624,7 @@ Map packageMap(String name, String version, [List dependencies]) {
|
| /// Describes a map representing a dependency on a package in the package
|
| /// repository.
|
| Map dependencyMap(String name, [String versionConstraint]) {
|
| - var url = port.then((p) => "http://localhost:$p");
|
| - var dependency = {"hosted": {"name": name, "url": url}};
|
| + var dependency = {"hosted": name};
|
| if (versionConstraint != null) dependency["version"] = versionConstraint;
|
| return dependency;
|
| }
|
|
|