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

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

Issue 586173002: Make binstubs run snapshots directly when possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 3 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
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 ca1e667932e180180c2e187fa998436be402c4de..9719f13f627fc37bf996439daa754ca483acaa53 100644
--- a/sdk/lib/_internal/pub/test/test_pub.dart
+++ b/sdk/lib/_internal/pub/test/test_pub.dart
@@ -476,16 +476,35 @@ void confirmPublish(ScheduledProcess pub) {
pub.writeLine("y");
}
+/// Gets the absolute path to [relPath], which is a relative path in the test
+/// sandbox.
+String _pathInSandbox(String relPath) {
+ return p.join(p.absolute(sandboxDir), relPath);
+}
+
+/// Gets the environment variables used to run pub in a test context.
+Map getPubTestEnvironment([Uri 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;
+}
+
/// Starts a Pub process and returns a [ScheduledProcess] that supports
/// interaction with that process.
///
/// Any futures in [args] will be resolved before the process is started.
ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
- String pathInSandbox(String relPath) {
- return p.join(p.absolute(sandboxDir), relPath);
- }
-
- ensureDir(pathInSandbox(appPath));
+ ensureDir(_pathInSandbox(appPath));
// Find a Dart executable we can use to spawn. Use the same one that was
// used to run this script itself.
@@ -510,17 +529,7 @@ ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
if (tokenEndpoint == null) tokenEndpoint = new Future.value();
var environmentFuture = tokenEndpoint.then((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();
- }
+ var environment = getPubTestEnvironment(tokenEndpoint);
// If there is a server running, tell pub what its URL is so hosted
// dependencies will look there.
@@ -535,7 +544,7 @@ ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
});
return new PubProcess.start(dartBin, dartArgs, environment: environmentFuture,
- workingDirectory: pathInSandbox(appPath),
+ workingDirectory: _pathInSandbox(appPath),
description: args.isEmpty ? 'pub' : 'pub ${args.first}');
}

Powered by Google App Engine
This is Rietveld 408576698