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

Unified Diff: sdk/lib/_internal/pub/test/test_pub.dart

Issue 19647002: Use PUB_HOSTED_SERVER to set server URL for pub tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « sdk/lib/_internal/pub/test/install/switch_source_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « sdk/lib/_internal/pub/test/install/switch_source_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698