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

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

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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_generated/test/serve_packages.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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 /// third_party/pkg. 99 /// third_party/pkg.
100 final _barbackDeps = { 100 final _barbackDeps = {
101 new VersionConstraint.parse("<0.15.0"): { 101 new VersionConstraint.parse("<0.15.0"): {
102 "source_maps": "0.9.4" 102 "source_maps": "0.9.4"
103 } 103 }
104 }; 104 };
105 105
106 /// Populates [_barbackVersions]. 106 /// Populates [_barbackVersions].
107 Map<Version, String> _findBarbackVersions() { 107 Map<Version, String> _findBarbackVersions() {
108 var versions = {}; 108 var versions = {};
109 var currentBarback = p.join(repoRoot, 'pkg', 'barback'); 109 var currentBarback = p.join(repoRoot, 'third_party', 'pkg', 'barback');
110 versions[new Pubspec.load(currentBarback, new SourceRegistry()).version] = 110 versions[new Pubspec.load(currentBarback, new SourceRegistry()).version] =
111 currentBarback; 111 currentBarback;
112 112
113 for (var dir in listDir(p.join(repoRoot, 'third_party', 'pkg'))) { 113 for (var dir in listDir(p.join(repoRoot, 'third_party', 'pkg'))) {
114 var basename = p.basename(dir); 114 var basename = p.basename(dir);
115 if (!basename.startsWith('barback')) continue; 115 if (!basename.startsWith('barback-')) continue;
116 versions[new Version.parse(split1(basename, '-').last)] = dir; 116 versions[new Version.parse(split1(basename, '-').last)] = dir;
117 } 117 }
118 118
119 return versions; 119 return versions;
120 } 120 }
121 121
122 /// Runs the tests in [callback] against all versions of barback in the repo 122 /// Runs the tests in [callback] against all versions of barback in the repo
123 /// that match [versionConstraint]. 123 /// that match [versionConstraint].
124 /// 124 ///
125 /// This is used to test that pub doesn't accidentally break older versions of 125 /// This is used to test that pub doesn't accidentally break older versions of
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 /// `true` if the current test spins up an HTTP server. 225 /// `true` if the current test spins up an HTTP server.
226 bool _hasServer = false; 226 bool _hasServer = false;
227 227
228 /// Converts [value] into a YAML string. 228 /// Converts [value] into a YAML string.
229 String yaml(value) => JSON.encode(value); 229 String yaml(value) => JSON.encode(value);
230 230
231 /// The full path to the created sandbox directory for an integration test. 231 /// The full path to the created sandbox directory for an integration test.
232 String get sandboxDir => _sandboxDir; 232 String get sandboxDir => _sandboxDir;
233 String _sandboxDir; 233 String _sandboxDir;
234 234
235 /// The path to the Dart repo's packages.
236 final String pkgPath =
237 p.absolute(p.join(p.dirname(Platform.executable), '../../../../pkg'));
238
239 /// The path of the package cache directory used for tests, relative to the 235 /// The path of the package cache directory used for tests, relative to the
240 /// sandbox directory. 236 /// sandbox directory.
241 final String cachePath = "cache"; 237 final String cachePath = "cache";
242 238
243 /// The path of the mock app directory used for tests, relative to the sandbox 239 /// The path of the mock app directory used for tests, relative to the sandbox
244 /// directory. 240 /// directory.
245 final String appPath = "myapp"; 241 final String appPath = "myapp";
246 242
247 /// The path of the packages directory in the mock app used for tests, relative 243 /// The path of the packages directory in the mock app used for tests, relative
248 /// to the sandbox directory. 244 /// to the sandbox directory.
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 if (sandbox != null) { 752 if (sandbox != null) {
757 for (var package in sandbox) { 753 for (var package in sandbox) {
758 dependencies[package] = '../$package'; 754 dependencies[package] = '../$package';
759 } 755 }
760 } 756 }
761 757
762 if (pkg != null) { 758 if (pkg != null) {
763 _addPackage(String package) { 759 _addPackage(String package) {
764 if (dependencies.containsKey(package)) return; 760 if (dependencies.containsKey(package)) return;
765 761
766 var packagePath; 762 var path;
767 if (package == 'barback' && _packageOverrides == null) { 763 if (package == 'barback' && _packageOverrides == null) {
768 throw new StateError( 764 throw new StateError(
769 "createLockFile() can only create a lock file " 765 "createLockFile() can only create a lock file "
770 "with a barback dependency within a withBarbackVersions() " "blo ck."); 766 "with a barback dependency within a withBarbackVersions() " "blo ck.");
771 } 767 }
772 768
773 if (_packageOverrides.containsKey(package)) { 769 if (_packageOverrides.containsKey(package)) {
774 packagePath = _packageOverrides[package]; 770 path = _packageOverrides[package];
775 } else { 771 } else {
776 packagePath = p.join(pkgPath, package); 772 path = packagePath(package);
777 } 773 }
778 774
779 dependencies[package] = packagePath; 775 dependencies[package] = path;
780 var pubspec = loadYaml(readTextFile(p.join(packagePath, 'pubspec.yaml'))); 776 var pubspec = loadYaml(readTextFile(p.join(path, 'pubspec.yaml')));
781 var packageDeps = pubspec['dependencies']; 777 var packageDeps = pubspec['dependencies'];
782 if (packageDeps == null) return; 778 if (packageDeps == null) return;
783 packageDeps.keys.forEach(_addPackage); 779 packageDeps.keys.forEach(_addPackage);
784 } 780 }
785 781
786 pkg.forEach(_addPackage); 782 pkg.forEach(_addPackage);
787 } 783 }
788 784
789 var lockFile = new LockFile.empty(); 785 var lockFile = new LockFile.empty();
790 dependencies.forEach((name, dependencyPath) { 786 dependencies.forEach((name, dependencyPath) {
791 var id = new PackageId(name, 'path', new Version(0, 0, 0), { 787 var id = new PackageId(name, 'path', new Version(0, 0, 0), {
792 'path': dependencyPath, 788 'path': dependencyPath,
793 'relative': p.isRelative(dependencyPath) 789 'relative': p.isRelative(dependencyPath)
794 }); 790 });
795 lockFile.packages[name] = id; 791 lockFile.packages[name] = id;
796 }); 792 });
797 793
798 if (hosted != null) { 794 if (hosted != null) {
799 hosted.forEach((name, version) { 795 hosted.forEach((name, version) {
800 var id = new PackageId(name, 'hosted', new Version.parse(version), name); 796 var id = new PackageId(name, 'hosted', new Version.parse(version), name);
801 lockFile.packages[name] = id; 797 lockFile.packages[name] = id;
802 }); 798 });
803 } 799 }
804 800
805 return lockFile; 801 return lockFile;
806 } 802 }
807 803
804 /// Returns the path to [package] within the repo.
805 String packagePath(String package) =>
806 dirExists(p.join(repoRoot, 'pkg', package)) ?
807 p.join(repoRoot, 'pkg', package) :
808 p.join(repoRoot, 'third_party', 'pkg', package);
809
808 /// Uses [client] as the mock HTTP client for this test. 810 /// Uses [client] as the mock HTTP client for this test.
809 /// 811 ///
810 /// Note that this will only affect HTTP requests made via http.dart in the 812 /// Note that this will only affect HTTP requests made via http.dart in the
811 /// parent process. 813 /// parent process.
812 void useMockClient(MockClient client) { 814 void useMockClient(MockClient client) {
813 var oldInnerClient = innerHttpClient; 815 var oldInnerClient = innerHttpClient;
814 innerHttpClient = client; 816 innerHttpClient = client;
815 currentSchedule.onComplete.schedule(() { 817 currentSchedule.onComplete.schedule(() {
816 innerHttpClient = oldInnerClient; 818 innerHttpClient = oldInnerClient;
817 }, 'de-activating the mock client'); 819 }, 'de-activating the mock client');
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 _lastMatcher.matches(item.last, matchState); 1005 _lastMatcher.matches(item.last, matchState);
1004 } 1006 }
1005 1007
1006 Description describe(Description description) { 1008 Description describe(Description description) {
1007 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 1009 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
1008 } 1010 }
1009 } 1011 }
1010 1012
1011 /// A [StreamMatcher] that matches multiple lines of output. 1013 /// A [StreamMatcher] that matches multiple lines of output.
1012 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); 1014 StreamMatcher emitsLines(String output) => inOrder(output.split("\n"));
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub_generated/test/serve_packages.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698