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

Unified Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 22986002: Add file watching to pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move some code around. Created 7 years, 4 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/serve/utils.dart
diff --git a/sdk/lib/_internal/pub/test/serve/utils.dart b/sdk/lib/_internal/pub/test/serve/utils.dart
index 3a083923e61868e62a4dec541b797e4aea32cc01..53756d67452abe93d8b049347dc1008ce4a34c12 100644
--- a/sdk/lib/_internal/pub/test/serve/utils.dart
+++ b/sdk/lib/_internal/pub/test/serve/utils.dart
@@ -67,4 +67,34 @@ void requestShould404(String urlPath) {
expect(response.statusCode, equals(404));
});
}, "request $urlPath");
+}
+
+/// Reads lines from pub serve's stdout until it prints the build success
+/// message.
+///
+/// The schedule will not proceed until the output is found. If not found, it
+/// will eventually time out.
+void waitForBuildSuccess() {
+ nextLine() {
+ return _pubServer.nextLine().then((line) {
+ if (line.contains("successfully")) return;
+
+ // This line wasn't it, so ignore it and keep trying.
+ return nextLine();
+ });
+ }
+
+ schedule(nextLine);
+}
+
+/// Returns a [Future] that completes after pumping the event queue [times]
+/// times. By default, this should pump the event queue enough times to allow
+/// any code to run, as long as it's not waiting on some external event.
+Future _pumpEventQueue([int times=20]) {
+ if (times == 0) return new Future.value();
+ // We use a delayed future to allow runAsync events to finish. The
+ // Future.value or Future() constructors use runAsync themselves and would
+ // therefore not wait for runAsync callbacks that are scheduled after invoking
+ // this method.
+ return new Future.delayed(Duration.ZERO, () => _pumpEventQueue(times - 1));
}

Powered by Google App Engine
This is Rietveld 408576698