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

Unified Diff: utils/tests/pub/test_pub.dart

Issue 11569046: Add a pub command for managing uploaders for packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 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 | « utils/tests/pub/pub_uploader_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/test_pub.dart
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
index 80137a0d5580a7fc73f3f8ba023ce963ca3a4522..c9479b3b6eab5f73cfff6085321532e8b723069c 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -566,7 +566,7 @@ String get testDirectory {
* Schedules a call to the Pub command-line utility. Runs Pub with [args] and
* validates that its results match [output], [error], and [exitCode].
*/
-void schedulePub({List<String> args, Pattern output, Pattern error,
+void schedulePub({List args, Pattern output, Pattern error,
Future<Uri> tokenEndpoint, int exitCode: 0}) {
_schedule((sandboxDir) {
return _doPub(runProcess, sandboxDir, args, tokenEndpoint)
@@ -596,37 +596,36 @@ void schedulePub({List<String> args, Pattern output, Pattern error,
});
}
-/**
- * A shorthand for [schedulePub] and [run] when no validation needs to be done
- * after Pub has been run.
- */
-void runPub({List<String> args, Pattern output, Pattern error,
- int exitCode: 0}) {
+/// A shorthand for [schedulePub] and [run] when no validation needs to be done
+/// after Pub has been run.
+///
+/// Any futures in [args] will be resolved before the process is started.
+void runPub({List args, Pattern output, Pattern error, int exitCode: 0}) {
schedulePub(args: args, output: output, error: error, exitCode: exitCode);
run();
}
/// Starts a Pub process and returns a [ScheduledProcess] that supports
/// interaction with that process.
-ScheduledProcess startPub({List<String> args}) {
+///
+/// Any futures in [args] will be resolved before the process is started.
+ScheduledProcess startPub({List args, Future<Uri> tokenEndpoint}) {
var process = _scheduleValue((sandboxDir) =>
- _doPub(startProcess, sandboxDir, args));
+ _doPub(startProcess, sandboxDir, args, tokenEndpoint));
return new ScheduledProcess("pub", process);
}
/// Like [startPub], but runs `pub lish` in particular with [server] used both
/// as the OAuth2 server (with "/token" as the token endpoint) and as the
/// package server.
-ScheduledProcess startPubLish(ScheduledServer server, {List<String> args}) {
- var process = _scheduleValue((sandboxDir) {
- return server.url.chain((url) {
- var tokenEndpoint = url.resolve('/token');
- if (args == null) args = [];
- args = flatten(['lish', '--server', url.toString(), args]);
- return _doPub(startProcess, sandboxDir, args, tokenEndpoint);
- });
- });
- return new ScheduledProcess("pub lish", process);
+///
+/// Any futures in [args] will be resolved before the process is started.
+ScheduledProcess startPubLish(ScheduledServer server, {List args}) {
+ var tokenEndpoint = server.url.transform((url) =>
+ url.resolve('/token').toString());
+ if (args == null) args = [];
+ args = flatten(['lish', '--server', tokenEndpoint, args]);
+ return startPub(args: args, tokenEndpoint: tokenEndpoint);
}
/// Handles the beginning confirmation process for uploading a packages.
@@ -649,10 +648,16 @@ void confirmPublish(ScheduledProcess pub) {
/// Calls [fn] with appropriately modified arguments to run a pub process. [fn]
/// should have the same signature as [startProcess], except that the returned
/// [Future] may have a type other than [Process].
-Future _doPub(Function fn, sandboxDir, List<String> args, Uri tokenEndpoint) {
+Future _doPub(Function fn, sandboxDir, List args, Future<Uri> tokenEndpoint) {
String pathInSandbox(path) => join(getFullPath(sandboxDir), path);
- return ensureDir(pathInSandbox(appPath)).chain((_) {
+ return Futures.wait([
+ ensureDir(pathInSandbox(appPath)),
+ _awaitObject(args),
+ tokenEndpoint == null ? new Future.immediate(null) : tokenEndpoint
+ ]).chain((results) {
+ var args = results[1];
+ var tokenEndpoint = results[2];
// Find a Dart executable we can use to spawn. Use the same one that was
// used to run this script itself.
var dartBin = new Options().executable;
« no previous file with comments | « utils/tests/pub/pub_uploader_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698