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

Unified Diff: utils/tests/pub/version_solver_test.dart

Issue 10690127: Add support to the version solver for sources that only have a single version per package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/source.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/version_solver_test.dart
diff --git a/utils/tests/pub/version_solver_test.dart b/utils/tests/pub/version_solver_test.dart
index f3a68c6f1c53738a37c249d440ab3c64474f8438..6d1cd02b06dca73abd4b549b91b6b02ea43c06e5 100644
--- a/utils/tests/pub/version_solver_test.dart
+++ b/utils/tests/pub/version_solver_test.dart
@@ -24,6 +24,7 @@ final couldNotSolve = 'unsolved';
Source source1;
Source source2;
+Source versionlessSource;
main() {
testResolve('no dependencies', {
@@ -103,6 +104,28 @@ main() {
'bang': '1.0.0'
});
+ testResolve('from versionless source', {
+ 'myapp 0.0.0': {
+ 'foo from versionless': 'any'
+ },
+ 'foo 1.2.3 from versionless': {}
+ }, result: {
+ 'myapp': '0.0.0',
+ 'foo': '1.2.3'
+ });
+
+ testResolve('transitively through versionless source', {
+ 'myapp 0.0.0': {
+ 'foo from versionless': 'any'
+ },
+ 'foo 1.2.3 from versionless': { 'bar': '>=1.0.0' },
Bob Nystrom 2012/07/11 16:55:13 Can you split this map onto the next line like the
nweiz 2012/07/11 19:11:37 Done.
+ 'bar 1.1.0': {}
+ }, result: {
+ 'myapp': '0.0.0',
+ 'foo': '1.2.3',
+ 'bar': '1.1.0'
+ });
+
testResolve('dependency back onto root package', {
'myapp 1.0.0': {
'foo': '1.0.0'
@@ -206,8 +229,10 @@ testResolve(description, packages, [result, error]) {
var sources = new SourceRegistry();
source1 = new MockSource('mock1');
source2 = new MockSource('mock2');
+ versionlessSource = new MockVersionlessSource();
sources.register(source1);
sources.register(source2);
+ sources.register(versionlessSource);
sources.setDefault(source1.name);
// Build the test package graph.
@@ -221,7 +246,7 @@ testResolve(description, packages, [result, error]) {
var name = parts[0];
var version = parts[1];
- var package = source.mockPackage(name, version, dependencies);
+ var package = source1.mockPackage(name, version, dependencies);
if (name == 'myapp') {
// Don't add the root package to the server, so we can verify that Pub
// doesn't try to look up information about the local package on the
@@ -317,13 +342,38 @@ class MockSource extends Source {
void addPackage(Package package) {
_packages.putIfAbsent(package.name, () => new Map<Version, Package>());
_packages[package.name][package.version] = package;
- return package;
}
String packageName(String description) =>
description.replaceFirst(new RegExp(@"-[^-]+$"), "");
}
+/**
+ * A source used for testing that doesn't natively understand versioning,
+ * similar to how the Git and SDK sources work.
+ */
+class MockVersionlessSource extends Source {
+ final Map<String, Package> _packages;
+
+ final String name = 'versionless';
+ final bool shouldCache = false;
+
+ MockVersionlessSource()
+ : _packages = <Package>{};
+
+ Future<bool> install(PackageId id, String path) {
+ throw 'no';
+ }
+
+ Future<Pubspec> describe(PackageId id) {
+ return new Future<Pubspec>.immediate(_packages[id.description].pubspec);
+ }
+
+ void addPackage(Package package) {
+ _packages[package.name] = package;
+ }
+}
+
Future fakeAsync(callback()) {
var completer = new Completer();
new Timer(0, (_) {
@@ -339,5 +389,7 @@ Pair<String, Source> parseSource(String name) {
switch (match[2]) {
case 'mock1': return new Pair<String, Source>(match[1], source1);
case 'mock2': return new Pair<String, Source>(match[1], source2);
+ case 'versionless':
+ return new Pair<String, Source>(match[1], versionlessSource);
}
}
« no previous file with comments | « utils/pub/source.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698