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

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

Issue 15347004: Gracefully handle pubspecs with dependencies using unknown sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests for unknown sources in lockfiles. Created 7 years, 7 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
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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 } 538 }
539 539
540 /// Converts a list of dependencies as passed to [package] into a hash as used 540 /// Converts a list of dependencies as passed to [package] into a hash as used
541 /// in a pubspec. 541 /// in a pubspec.
542 Future<Map> dependencyListToMap(List<Map> dependencies) { 542 Future<Map> dependencyListToMap(List<Map> dependencies) {
543 return awaitObject(dependencies).then((resolvedDependencies) { 543 return awaitObject(dependencies).then((resolvedDependencies) {
544 var result = <String, Map>{}; 544 var result = <String, Map>{};
545 for (var dependency in resolvedDependencies) { 545 for (var dependency in resolvedDependencies) {
546 var keys = dependency.keys.where((key) => key != "version"); 546 var keys = dependency.keys.where((key) => key != "version");
547 var sourceName = only(keys); 547 var sourceName = only(keys);
548 var source;
549 switch (sourceName) {
550 case "git":
551 source = new GitSource();
552 break;
553 case "hosted":
554 source = new HostedSource();
555 break;
556 case "path":
557 source = new PathSource();
558 break;
559 default:
560 throw new Exception('Unknown source "$sourceName"');
561 }
562 548
563 result[_packageName(sourceName, dependency[sourceName])] = dependency; 549 result[_packageName(sourceName, dependency[sourceName])] = dependency;
564 } 550 }
565 return result; 551 return result;
566 }); 552 });
567 } 553 }
568 554
569 /// Return the name for the package described by [description] and from 555 /// Return the name for the package described by [description] and from
570 /// [sourceName]. 556 /// [sourceName].
571 String _packageName(String sourceName, description) { 557 String _packageName(String sourceName, description) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 bool matches(item, MatchState matchState) { 682 bool matches(item, MatchState matchState) {
697 if (item is! Pair) return false; 683 if (item is! Pair) return false;
698 return _firstMatcher.matches(item.first, matchState) && 684 return _firstMatcher.matches(item.first, matchState) &&
699 _lastMatcher.matches(item.last, matchState); 685 _lastMatcher.matches(item.last, matchState);
700 } 686 }
701 687
702 Description describe(Description description) { 688 Description describe(Description description) {
703 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 689 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
704 } 690 }
705 } 691 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/pubspec_test.dart ('k') | sdk/lib/_internal/pub/test/update/unknown_source_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698