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 6a6fec12e1520cd4da2a21641bd2816c0303d528..51eb18a0fcb4290a1d83dfa1e8df1616a31a3208 100644 |
--- a/sdk/lib/_internal/pub/test/test_pub.dart |
+++ b/sdk/lib/_internal/pub/test/test_pub.dart |
@@ -486,7 +486,7 @@ String _pathInSandbox(String relPath) { |
} |
/// Gets the environment variables used to run pub in a test context. |
-Map getPubTestEnvironment([String tokenEndpoint]) { |
+Future<Map> getPubTestEnvironment([String tokenEndpoint]) async { |
var environment = {}; |
environment['_PUB_TESTING'] = 'true'; |
environment['PUB_CACHE'] = _pathInSandbox(cachePath); |
@@ -498,6 +498,13 @@ Map getPubTestEnvironment([String tokenEndpoint]) { |
environment['_PUB_TEST_TOKEN_ENDPOINT'] = tokenEndpoint.toString(); |
} |
+ if (_hasServer) { |
+ return port.then((p) { |
+ environment['PUB_HOSTED_URL'] = "http://localhost:$p"; |
+ return environment; |
+ }); |
+ } |
+ |
return environment; |
} |
@@ -534,20 +541,9 @@ ScheduledProcess startPub({List args, Future<String> tokenEndpoint, |
dartArgs.addAll(args); |
if (tokenEndpoint == null) tokenEndpoint = new Future.value(); |
- var environmentFuture = tokenEndpoint.then((tokenEndpoint) { |
- var pubEnvironment = getPubTestEnvironment(tokenEndpoint); |
- |
- // If there is a server running, tell pub what its URL is so hosted |
- // dependencies will look there. |
- if (_hasServer) { |
- return port.then((p) { |
- pubEnvironment['PUB_HOSTED_URL'] = "http://localhost:$p"; |
- return pubEnvironment; |
- }); |
- } |
- |
- return pubEnvironment; |
- }).then((pubEnvironment) { |
+ var environmentFuture = tokenEndpoint |
+ .then((tokenEndpoint) => getPubTestEnvironment(tokenEndpoint)) |
+ .then((pubEnvironment) { |
if (environment != null) pubEnvironment.addAll(environment); |
return pubEnvironment; |
}); |
@@ -854,6 +850,11 @@ Map packageVersionApiMap(Map pubspec, {bool full: false}) { |
return map; |
} |
+/// Returns the name of the shell script for a binstub named [name]. |
+/// |
+/// Adds a ".bat" extension on Windows. |
+String binStubName(String name) => Platform.isWindows ? '$name.bat' : name; |
+ |
/// Compares the [actual] output from running pub with [expected]. |
/// |
/// If [expected] is a [String], ignores leading and trailing whitespace |