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

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

Issue 482053002: Precompile dependencies' executables for use with "pub run". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make our SDK version file match the SDK's. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/test/snapshot/upgrades_snapshot_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. 5 /// Test infrastructure for testing pub.
6 /// 6 ///
7 /// Unlike typical unit tests, most pub tests are integration tests that stage 7 /// Unlike typical unit tests, most pub tests are integration tests that stage
8 /// some stuff on the file system, run pub, and then validate the results. This 8 /// some stuff on the file system, run pub, and then validate the results. This
9 /// library provides an API to build tests like that. 9 /// library provides an API to build tests like that.
10 library test_pub; 10 library test_pub;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 /// 248 ///
249 /// [pubspecs] is a list of unserialized pubspecs representing the packages to 249 /// [pubspecs] is a list of unserialized pubspecs representing the packages to
250 /// serve. 250 /// serve.
251 /// 251 ///
252 /// If [replace] is false, subsequent calls to [servePackages] will add to the 252 /// If [replace] is false, subsequent calls to [servePackages] will add to the
253 /// set of packages that are being served. Previous packages will continue to be 253 /// set of packages that are being served. Previous packages will continue to be
254 /// served. Otherwise, the previous packages will no longer be served. 254 /// served. Otherwise, the previous packages will no longer be served.
255 /// 255 ///
256 /// If [contents] is given, its contents are added to every served 256 /// If [contents] is given, its contents are added to every served
257 /// package. 257 /// package.
258 ///
259 /// If [serveBarback] is true, the repo versions of barback and its dependencies
260 /// will be served as well.
258 void servePackages(List<Map> pubspecs, {bool replace: false, 261 void servePackages(List<Map> pubspecs, {bool replace: false,
259 Iterable<d.Descriptor> contents}) { 262 Iterable<d.Descriptor> contents, bool serveBarback: false}) {
260 if (_servedPackages == null || _servedPackageDir == null) { 263 if (_servedPackages == null || _servedPackageDir == null) {
261 _servedPackages = <String, List<Map>>{}; 264 _servedPackages = <String, List<Map>>{};
262 _servedApiPackageDir = d.dir('packages', []); 265 _servedApiPackageDir = d.dir('packages', []);
263 _servedPackageDir = d.dir('packages', []); 266 _servedPackageDir = d.dir('packages', []);
264 serve([ 267 serve([
265 d.dir('api', [_servedApiPackageDir]), 268 d.dir('api', [_servedApiPackageDir]),
266 _servedPackageDir 269 _servedPackageDir
267 ]); 270 ]);
268 271
269 currentSchedule.onComplete.schedule(() { 272 currentSchedule.onComplete.schedule(() {
270 _servedPackages = null; 273 _servedPackages = null;
271 _servedApiPackageDir = null; 274 _servedApiPackageDir = null;
272 _servedPackageDir = null; 275 _servedPackageDir = null;
273 }, 'cleaning up served packages'); 276 }, 'cleaning up served packages');
274 } 277 }
275 278
276 schedule(() { 279 schedule(() {
277 return awaitObject(pubspecs).then((resolvedPubspecs) { 280 return awaitObject(pubspecs).then((resolvedPubspecs) {
278 if (replace) _servedPackages.clear(); 281 if (replace) _servedPackages.clear();
279 282
280 for (var pubspec in resolvedPubspecs) { 283 for (var pubspec in resolvedPubspecs) {
281 var name = pubspec['name']; 284 var name = pubspec['name'];
282 var version = pubspec['version']; 285 var version = pubspec['version'];
283 var versions = _servedPackages.putIfAbsent(name, () => []); 286 var versions = _servedPackages.putIfAbsent(name, () => []);
284 versions.add(pubspec); 287 versions.add(pubspec);
285 } 288 }
286 289
290 var repoPackages = new Set();
291 if (serveBarback) {
292 _addPackage(name) {
293 if (_servedPackages.containsKey(name)) return;
294 repoPackages.add(name);
295
296 var pubspec = new Map.from(loadYaml(
297 readTextFile(path.join(repoRoot, 'pkg', name, 'pubspec.yaml'))));
298
299 // Remove any SDK constraints since we don't have a valid SDK version
300 // while testing.
301 pubspec.remove('environment');
302
303 _servedPackages[name] = [pubspec];
304 if (pubspec.containsKey('dependencies')) {
305 pubspec['dependencies'].keys.forEach(_addPackage);
306 }
307 }
308
309 _addPackage('barback');
310 }
311
287 _servedApiPackageDir.contents.clear(); 312 _servedApiPackageDir.contents.clear();
288 _servedPackageDir.contents.clear(); 313 _servedPackageDir.contents.clear();
289 for (var name in _servedPackages.keys) { 314 for (var name in _servedPackages.keys) {
290 _servedApiPackageDir.contents.addAll([ 315 _servedApiPackageDir.contents.addAll([
291 d.file('$name', JSON.encode({ 316 d.file('$name', JSON.encode({
292 'name': name, 317 'name': name,
293 'uploaders': ['nweiz@google.com'], 318 'uploaders': ['nweiz@google.com'],
294 'versions': _servedPackages[name].map(packageVersionApiMap).toList() 319 'versions': _servedPackages[name].map(packageVersionApiMap).toList()
295 })), 320 })),
296 d.dir(name, [ 321 d.dir(name, [
297 d.dir('versions', _servedPackages[name].map((pubspec) { 322 d.dir('versions', _servedPackages[name].map((pubspec) {
298 return d.file(pubspec['version'], JSON.encode( 323 return d.file(pubspec['version'], JSON.encode(
299 packageVersionApiMap(pubspec, full: true))); 324 packageVersionApiMap(pubspec, full: true)));
300 })) 325 }))
301 ]) 326 ])
302 ]); 327 ]);
303 328
304 _servedPackageDir.contents.add(d.dir(name, [ 329 _servedPackageDir.contents.add(d.dir(name, [
305 d.dir('versions', _servedPackages[name].map((pubspec) { 330 d.dir('versions', _servedPackages[name].map((pubspec) {
306 var version = pubspec['version']; 331 var version = pubspec['version'];
307 332
333 if (repoPackages.contains(name)) {
334 return d.tar('$version.tar.gz', [
335 d.file('pubspec.yaml', JSON.encode(pubspec)),
336 new d.DirectoryDescriptor.fromFilesystem('lib',
337 path.join(repoRoot, 'pkg', name, 'lib'))
338 ]);
339 }
340
308 var archiveContents = [ 341 var archiveContents = [
309 d.file('pubspec.yaml', JSON.encode(pubspec)), 342 d.file('pubspec.yaml', JSON.encode(pubspec)),
310 d.libDir(name, '$name $version') 343 d.libDir(name, '$name $version')
311 ]; 344 ];
312 345
313 if (contents != null) { 346 if (contents != null) {
314 archiveContents.addAll(contents); 347 archiveContents.addAll(contents);
315 } 348 }
316 349
317 return d.tar('$version.tar.gz', archiveContents); 350 return d.tar('$version.tar.gz', archiveContents);
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 _lastMatcher.matches(item.last, matchState); 1073 _lastMatcher.matches(item.last, matchState);
1041 } 1074 }
1042 1075
1043 Description describe(Description description) { 1076 Description describe(Description description) {
1044 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 1077 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
1045 } 1078 }
1046 } 1079 }
1047 1080
1048 /// A [StreamMatcher] that matches multiple lines of output. 1081 /// A [StreamMatcher] that matches multiple lines of output.
1049 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); 1082 StreamMatcher emitsLines(String output) => inOrder(output.split("\n"));
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/snapshot/upgrades_snapshot_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698