Validate that a package doesn't depend on itself.

BUG=7045

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16614 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
nweiz@google.com 2013-01-03 22:18:46 +00:00
parent e481bdca9a
commit 09afa8f485
2 changed files with 20 additions and 0 deletions

View file

@ -23,6 +23,14 @@ class DependencyValidator extends Validator {
return _warnAboutSource(dependency);
}
if (dependency.name == entrypoint.root.name) {
warnings.add('You don\'t need to explicitly depend on your own '
'package.\n'
'Pub enables "package:${entrypoint.root.name}" imports '
'implicitly.');
return new Future.immediate(null);
}
if (dependency.constraint.isAny &&
// TODO(nweiz): once we have development dependencies (issue 5358), we
// should warn about unittest. Until then, it's reasonable not to put

View file

@ -531,5 +531,17 @@ main() {
});
});
});
test('has a hosted dependency on itself', () {
dir(appPath, [
libPubspec("test_pkg", "1.0.0", [
{'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}}
])
]).scheduleCreate();
expectValidationWarning(dependency);
run();
});
});
}