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

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

Issue 745153002: Make pub's binstubs resilient to changes in snapshot format. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years 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_generated/test/global/binstubs/utils.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_generated/test/test_pub.dart
diff --git a/sdk/lib/_internal/pub_generated/test/test_pub.dart b/sdk/lib/_internal/pub_generated/test/test_pub.dart
index a3e68022340cfdf4c456101852b497a93fcefbbd..de82952ca7ff2f01c39a88d3cff1e85e709b3f46 100644
--- a/sdk/lib/_internal/pub_generated/test/test_pub.dart
+++ b/sdk/lib/_internal/pub_generated/test/test_pub.dart
@@ -495,19 +495,38 @@ String _pathInSandbox(String relPath) {
}
/// Gets the environment variables used to run pub in a test context.
-Map getPubTestEnvironment([String tokenEndpoint]) {
- var environment = {};
- environment['_PUB_TESTING'] = 'true';
- environment['PUB_CACHE'] = _pathInSandbox(cachePath);
-
- // Ensure a known SDK version is set for the tests that rely on that.
- environment['_PUB_TEST_SDK_VERSION'] = "0.1.2+3";
-
- if (tokenEndpoint != null) {
- environment['_PUB_TEST_TOKEN_ENDPOINT'] = tokenEndpoint.toString();
- }
-
- return environment;
+Future<Map> getPubTestEnvironment([String tokenEndpoint]) {
+ final completer0 = new Completer();
+ scheduleMicrotask(() {
+ try {
+ var environment = {};
+ environment['_PUB_TESTING'] = 'true';
+ environment['PUB_CACHE'] = _pathInSandbox(cachePath);
+ environment['_PUB_TEST_SDK_VERSION'] = "0.1.2+3";
+ join0() {
+ join1() {
+ completer0.complete(environment);
+ }
+ if (_hasServer) {
+ completer0.complete(port.then(((p) {
+ environment['PUB_HOSTED_URL'] = "http://localhost:$p";
+ return environment;
+ })));
+ } else {
+ join1();
+ }
+ }
+ if (tokenEndpoint != null) {
+ environment['_PUB_TEST_TOKEN_ENDPOINT'] = tokenEndpoint.toString();
+ join0();
+ } else {
+ join0();
+ }
+ } catch (e, s) {
+ completer0.completeError(e, s);
+ }
+ });
+ return completer0.future;
}
/// Starts a Pub process and returns a [ScheduledProcess] that supports
@@ -543,20 +562,8 @@ ScheduledProcess startPub({List args, Future<String> tokenEndpoint, Map<String,
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;
});
@@ -868,6 +875,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
« no previous file with comments | « sdk/lib/_internal/pub_generated/test/global/binstubs/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698