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

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

Issue 21147002: Install before starting the server if the lockfile is out of date. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 5 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 a74498ba9460d6d75fc07e74d2e3314d3d99307a..8a89f29bbb1261b1d2ba3adc89f9039d02184a3a 100644
--- a/sdk/lib/_internal/pub/test/serve/utils.dart
+++ b/sdk/lib/_internal/pub/test/serve/utils.dart
@@ -21,15 +21,41 @@ ScheduledProcess _pubServer;
int _port;
/// Schedules starting the "pub serve" process.
-void startPubServe() {
+///
+/// If [shouldInstallFirst] is `true`, then validates that pub install is run
nweiz 2013/07/30 19:34:36 Nit: remove "then"
Bob Nystrom 2013/07/30 21:35:32 Done.
+/// first.
+void startPubServe({bool shouldInstallFirst: false}) {
// Use port 0 to get an ephemeral port.
_pubServer = startPub(args: ["serve", "--port=0"]);
- expect(_pubServer.nextLine().then((line) {
- var match = new RegExp(r"localhost:(\d+)").firstMatch(line);
- assert(match != null);
- _port = int.parse(match[1]);
- }), completes);
+ if (shouldInstallFirst) {
+ schedule(() {
+ return _pubServer.nextLine().then((line1) {
+ expect(line1, startsWith("Dependencies have changed"));
+ return _pubServer.nextLine();
+ }).then((line2) {
+ expect(line2, startsWith("Resolving dependencies..."));
+ return _pubServer.nextLine();
+ }).then((line3) {
+ expect(line3, equals("Dependencies installed!"));
+ return _pubServer.nextLine();
+ }).then((line4) {
+ _parsePort(line4);
+ });
+ });
nweiz 2013/07/30 19:34:36 Since [nextLine] is scheduled internally, you can
Bob Nystrom 2013/07/30 21:35:32 Done.
+
+ return;
+ }
+
+ expect(_pubServer.nextLine().then(_parsePort), completes);
+}
+
+/// Parses the port number from the "Serving blah on localhost:1234" line
+/// printed by pub serve.
+void _parsePort(String line) {
+ var match = new RegExp(r"localhost:(\d+)").firstMatch(line);
+ assert(match != null);
+ _port = int.parse(match[1]);
}
void endPubServe() {

Powered by Google App Engine
This is Rietveld 408576698