Index: utils/tests/pub/test_pub.dart |
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart |
index ef6cd7f6d76f450822704007d232e8f052cdbd40..308382a7b97fa7323eb9ef98f748c731d0d38570 100644 |
--- a/utils/tests/pub/test_pub.dart |
+++ b/utils/tests/pub/test_pub.dart |
@@ -268,7 +268,12 @@ Descriptor libDir(String name, [String code]) { |
* [version], and [dependencies]. |
*/ |
Map package(String name, String version, [List dependencies]) { |
- var package = {"name": name, "version": version}; |
+ var package = { |
+ "name": name, |
+ "version": version, |
+ "author": "Nathan Weizenbaum <nweiz@google.com>", |
+ "homepage": "http://pub.dartlang.org" |
+ }; |
if (dependencies != null) { |
package["dependencies"] = _dependencyListToMap(dependencies); |
} |
@@ -1349,6 +1354,34 @@ class ScheduledProcess { |
}); |
} |
+ /// Reads the remaining stdout from the process. This should only be called |
+ /// after kill() or shouldExit(). |
+ Future<String> remainingStdout() { |
+ if (!_endScheduled) { |
+ throw new StateError("remainingStdout() should only be called after " |
+ "kill() or shouldExit()."); |
+ } |
+ |
+ return _scheduleValue((_) { |
+ return timeout(_stdout.chain(consumeStringInputStream), 5000, |
Bob Nystrom
2012/12/05 18:57:40
Make a constant for all of these "5000"s, please.
nweiz
2012/12/05 21:59:59
Done.
|
+ "waiting for the last stdout line from process $name"); |
+ }); |
+ } |
+ |
+ /// Reads the remaining stderr from the process. This should only be called |
+ /// after kill() or shouldExit(). |
+ Future<String> remainingStderr() { |
+ if (!_endScheduled) { |
+ throw new StateError("remainingStderr() should only be called after " |
+ "kill() or shouldExit()."); |
+ } |
+ |
+ return _scheduleValue((_) { |
+ return timeout(_stderr.chain(consumeStringInputStream), 5000, |
+ "waiting for the last stderr line from process $name"); |
+ }); |
+ } |
+ |
/// Writes [line] to the process as stdin. |
void writeLine(String line) { |
_schedule((_) => _process.transform((p) => p.stdin.writeString('$line\n'))); |
@@ -1411,6 +1444,9 @@ class ScheduledServer { |
/// The queue of handlers to run for upcoming requests. |
final _handlers = new Queue<Future>(); |
+ /// The requests to be ignored. |
+ final _ignored = new Set<Pair<String, String>>(); |
+ |
ScheduledServer._(this._server); |
/// Creates a new server listening on an automatically-allocated port on |
@@ -1456,14 +1492,19 @@ class ScheduledServer { |
_handlers.add(handlerCompleter.future); |
} |
+ /// Ignore all requests with the given [method] and [path]. If one is |
+ /// received, don't respond to it. |
+ void ignore(String method, String path) => |
+ _ignored.add(new Pair(method, path)); |
+ |
/// Raises an error complaining of an unexpected request. |
void _awaitHandle(HttpRequest request, HttpResponse response) { |
+ if (_ignored.contains(new Pair(request.method, request.path))) return; |
var future = timeout(new Future.immediate(null).chain((_) { |
- var handlerFuture = _handlers.removeFirst(); |
- if (handlerFuture == null) { |
+ if (_handlers.isEmpty) { |
fail('Unexpected ${request.method} request to ${request.path}.'); |
} |
- return handlerFuture; |
+ return _handlers.removeFirst(); |
}).transform((handler) { |
handler(request, response); |
}), 5000, "waiting for a handler for ${request.method} ${request.path}"); |