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

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

Issue 334363004: Gracefully handle a missing locked version in pub get. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/test/get/hosted/unlock_if_version_doesnt_exist_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 file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS 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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 /// A map from package names to parsed pubspec maps for those packages. This 212 /// A map from package names to parsed pubspec maps for those packages. This
213 /// represents the packages currently being served by [servePackages], and is 213 /// represents the packages currently being served by [servePackages], and is
214 /// `null` if [servePackages] has not yet been called for this test. 214 /// `null` if [servePackages] has not yet been called for this test.
215 Map<String, List<Map>> _servedPackages; 215 Map<String, List<Map>> _servedPackages;
216 216
217 /// Creates an HTTP server that replicates the structure of pub.dartlang.org. 217 /// Creates an HTTP server that replicates the structure of pub.dartlang.org.
218 /// [pubspecs] is a list of unserialized pubspecs representing the packages to 218 /// [pubspecs] is a list of unserialized pubspecs representing the packages to
219 /// serve. 219 /// serve.
220 /// 220 ///
221 /// Subsequent calls to [servePackages] will add to the set of packages that 221 /// If [replace] is false, subsequent calls to [servePackages] will add to the
222 /// are being served. Previous packages will continue to be served. 222 /// set of packages that are being served. Previous packages will continue to be
223 void servePackages(List<Map> pubspecs) { 223 /// served. Otherwise, the previous packages will no longer be served.
224 void servePackages(List<Map> pubspecs, {bool replace: false}) {
224 if (_servedPackages == null || _servedPackageDir == null) { 225 if (_servedPackages == null || _servedPackageDir == null) {
225 _servedPackages = <String, List<Map>>{}; 226 _servedPackages = <String, List<Map>>{};
226 _servedApiPackageDir = d.dir('packages', []); 227 _servedApiPackageDir = d.dir('packages', []);
227 _servedPackageDir = d.dir('packages', []); 228 _servedPackageDir = d.dir('packages', []);
228 serve([ 229 serve([
229 d.dir('api', [_servedApiPackageDir]), 230 d.dir('api', [_servedApiPackageDir]),
230 _servedPackageDir 231 _servedPackageDir
231 ]); 232 ]);
232 233
233 currentSchedule.onComplete.schedule(() { 234 currentSchedule.onComplete.schedule(() {
234 _servedPackages = null; 235 _servedPackages = null;
235 _servedApiPackageDir = null; 236 _servedApiPackageDir = null;
236 _servedPackageDir = null; 237 _servedPackageDir = null;
237 }, 'cleaning up served packages'); 238 }, 'cleaning up served packages');
238 } 239 }
239 240
240 schedule(() { 241 schedule(() {
241 return awaitObject(pubspecs).then((resolvedPubspecs) { 242 return awaitObject(pubspecs).then((resolvedPubspecs) {
243 if (replace) _servedPackages.clear();
244
242 for (var spec in resolvedPubspecs) { 245 for (var spec in resolvedPubspecs) {
243 var name = spec['name']; 246 var name = spec['name'];
244 var version = spec['version']; 247 var version = spec['version'];
245 var versions = _servedPackages.putIfAbsent(name, () => []); 248 var versions = _servedPackages.putIfAbsent(name, () => []);
246 versions.add(spec); 249 versions.add(spec);
247 } 250 }
248 251
249 _servedApiPackageDir.contents.clear(); 252 _servedApiPackageDir.contents.clear();
250 _servedPackageDir.contents.clear(); 253 _servedPackageDir.contents.clear();
251 for (var name in _servedPackages.keys) { 254 for (var name in _servedPackages.keys) {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 _lastMatcher.matches(item.last, matchState); 911 _lastMatcher.matches(item.last, matchState);
909 } 912 }
910 913
911 Description describe(Description description) { 914 Description describe(Description description) {
912 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 915 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
913 } 916 }
914 } 917 }
915 918
916 /// A [StreamMatcher] that matches multiple lines of output. 919 /// A [StreamMatcher] that matches multiple lines of output.
917 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); 920 StreamMatcher emitsLines(String output) => inOrder(output.split("\n"));
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/get/hosted/unlock_if_version_doesnt_exist_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698