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

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

Issue 83173011: Make sure pub build/serve get at the right time: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/gets_first_if_transitive_dependency_is_not_installed_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub_tests; 5 library pub_tests;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Dart2js can take a long time to compile dart code, so we increase the 107 // Dart2js can take a long time to compile dart code, so we increase the
108 // timeout to cope with that. 108 // timeout to cope with that.
109 currentSchedule.timeout = new Duration(seconds: 15); 109 currentSchedule.timeout = new Duration(seconds: 15);
110 110
111 return startPub(args: pubArgs); 111 return startPub(args: pubArgs);
112 } 112 }
113 113
114 /// Schedules starting the "pub serve" process and records its port number for 114 /// Schedules starting the "pub serve" process and records its port number for
115 /// future requests. 115 /// future requests.
116 /// 116 ///
117 /// If [shouldGetFirst] is `true`, validates that pub get is run first. 117 /// If [shouldGetFirst] is `true`, validates that pub get is run first. In that
118 /// case, you can also pass [numDownloads] to specify how many packages should
119 /// be downloaded during the get.
118 /// 120 ///
119 /// Returns the `pub serve` process. 121 /// Returns the `pub serve` process.
120 ScheduledProcess pubServe({bool shouldGetFirst: false, 122 ScheduledProcess pubServe({bool shouldGetFirst: false,
121 Iterable<String> args}) { 123 Iterable<String> args, int numDownloads: 0}) {
122 _pubServer = startPubServe(args); 124 _pubServer = startPubServe(args);
123 125
124 currentSchedule.onComplete.schedule(() { 126 currentSchedule.onComplete.schedule(() {
125 if (_webSocket != null) { 127 if (_webSocket != null) {
126 _webSocket.close(); 128 _webSocket.close();
127 _webSocket = null; 129 _webSocket = null;
128 _webSocketBroadcastStream = null; 130 _webSocketBroadcastStream = null;
129 } 131 }
130 }); 132 });
131 133
132 if (shouldGetFirst) { 134 if (shouldGetFirst) {
133 expect(_pubServer.nextLine(), 135 expect(_pubServer.nextLine(),
134 completion(anyOf( 136 completion(anyOf(
135 startsWith("Your pubspec has changed"), 137 startsWith("Your pubspec has changed"),
136 startsWith("You don't have a lockfile")))); 138 startsWith("You don't have a lockfile"),
139 startsWith("You are missing some dependencies"))));
137 expect(_pubServer.nextLine(), 140 expect(_pubServer.nextLine(),
138 completion(startsWith("Resolving dependencies..."))); 141 completion(startsWith("Resolving dependencies...")));
142
143 for (var i = 0; i < numDownloads; i++) {
144 expect(_pubServer.nextLine(),
145 completion(startsWith("Downloading")));
146 }
147
139 expect(_pubServer.nextLine(), 148 expect(_pubServer.nextLine(),
140 completion(equals("Got dependencies!"))); 149 completion(equals("Got dependencies!")));
141 } 150 }
142 151
143 expect(_pubServer.nextLine().then(_parsePort), completes); 152 expect(_pubServer.nextLine().then(_parsePort), completes);
144 return _pubServer; 153 return _pubServer;
145 } 154 }
146 155
147 /// Parses the port number from the "Serving blah on 127.0.0.1:1234" line 156 /// Parses the port number from the "Serving blah on 127.0.0.1:1234" line
148 /// printed by pub serve. 157 /// printed by pub serve.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 /// socket. It omitted, request is JSON encoded to a string first. 240 /// socket. It omitted, request is JSON encoded to a string first.
232 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { 241 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) {
233 schedule(() => _ensureWebSocket().then((_) { 242 schedule(() => _ensureWebSocket().then((_) {
234 if (encodeRequest) request = JSON.encode(request); 243 if (encodeRequest) request = JSON.encode(request);
235 _webSocket.add(request); 244 _webSocket.add(request);
236 return _webSocketBroadcastStream.first.then((value) { 245 return _webSocketBroadcastStream.first.then((value) {
237 expect(JSON.decode(value), expectation); 246 expect(JSON.decode(value), expectation);
238 }); 247 });
239 }), "send $request to web socket and expect reply that $expectation"); 248 }), "send $request to web socket and expect reply that $expectation");
240 } 249 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/gets_first_if_transitive_dependency_is_not_installed_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698