Skip to content
Snippets Groups Projects
Commit ca40b0a8 authored by rnystrom@google.com's avatar rnystrom@google.com
Browse files

Handle circular dependencies on the root package when checking SDK constraints.

BUG=dartbug.com/8364

Review URL: https://codereview.chromium.org//12211061

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@18198 260f80e4-7a28-3924-810f-c04153c831b5
parent 2294b8c0
No related branches found
No related tags found
No related merge requests found
......@@ -157,13 +157,19 @@ class Entrypoint {
var id = lockFile.packages[ref.name];
visited.add(ref.name);
var future = cache.describe(id);
var future;
if (ref.name == root.name) {
future = new Future<Pubspec>.immediate(root.pubspec);
} else {
future = cache.describe(id);
}
group.add(future.then(visitPackage));
}
return pubspec;
}
visited.add(root.name);
visitPackage(root.pubspec);
return group.future;
});
......
......@@ -63,6 +63,8 @@ class SystemCache {
/// Gets the package identified by [id]. If the package is already cached,
/// reads it from the cache. Otherwise, requests it from the source.
Future<Pubspec> describe(PackageId id) {
if (id.isRoot) throw new ArgumentError("Cannot describe the root package.");
// Try to get it from the system cache first.
if (id.source.shouldCache) {
return id.systemCacheDirectory.then((packageDir) {
......
......@@ -117,5 +117,40 @@ main() {
or adding a version constraint to use an older version of a package.
""");
});
integration("handles a circular dependency on the root package", () {
// Using an SDK source, but this should be true of all sources.
dir(sdkPath, [
dir("pkg", [
dir("foo", [
libPubspec("foo", "0.0.1", sdk: ">3.0.0", deps: [
{"sdk": "myapp"}
]),
libDir("foo")
])
])
]).scheduleCreate();
dir(appPath, [
pubspec({
"name": "myapp",
"dependencies": {
"foo": { "sdk": "foo" }
},
"environment": {"sdk": ">2.0.0"}
})
]).scheduleCreate();
schedulePub(args: [command],
error:
"""
Some packages are not compatible with your SDK version 0.1.2+3:
- 'myapp' requires >2.0.0
- 'foo' requires >3.0.0
You may be able to resolve this by upgrading to the latest Dart SDK
or adding a version constraint to use an older version of a package.
""");
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment