Chromium Code Reviews

Unified Diff: sdk/lib/_internal/pub/test/dependency_override_test.dart

Issue 74013007: Hook up dependency overrides to the rest of pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: sdk/lib/_internal/pub/test/dependency_override_test.dart
diff --git a/sdk/lib/_internal/pub/test/dependency_override_test.dart b/sdk/lib/_internal/pub/test/dependency_override_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c930dd5b84527fa4fb890ff437341a4c50fb40dc
--- /dev/null
+++ b/sdk/lib/_internal/pub/test/dependency_override_test.dart
@@ -0,0 +1,113 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'descriptor.dart' as d;
+import 'test_pub.dart';
+
+main() {
+ initConfig();
+ forBothPubGetAndUpgrade((command) {
+ integration("chooses best version matching override constraint", () {
+ servePackages([
+ packageMap("foo", "1.0.0"),
+ packageMap("foo", "2.0.0"),
+ packageMap("foo", "3.0.0")
+ ]);
+
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "myapp",
+ "dependencies": {
+ "foo": ">2.0.0"
+ },
+ "dependency_overrides": {
+ "foo": "<3.0.0"
+ }
+ })
+ ]).create();
+
+ pubCommand(command);
+
+ d.packagesDir({
+ "foo": "2.0.0"
+ }).validate();
+ });
+
+ integration("treats override as implicit dependency", () {
+ servePackages([
+ packageMap("foo", "1.0.0")
+ ]);
+
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "myapp",
+ "dependency_overrides": {
+ "foo": "any"
+ }
+ })
+ ]).create();
+
+ pubCommand(command);
+
+ d.packagesDir({
+ "foo": "1.0.0"
+ }).validate();
+ });
+
+ integration("ignores other constraints on overridden package", () {
+ servePackages([
+ packageMap("foo", "1.0.0"),
+ packageMap("foo", "2.0.0"),
+ packageMap("foo", "3.0.0"),
+ packageMap("bar", "1.0.0", {"foo": "5.0.0-nonexistent"})
+ ]);
+
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "myapp",
+ "dependencies": {
+ "bar": "any"
+ },
+ "dependency_overrides": {
+ "foo": "<3.0.0"
+ }
+ })
+ ]).create();
+
+ pubCommand(command);
+
+ d.packagesDir({
+ "foo": "2.0.0",
+ "bar": "1.0.0"
+ }).validate();
+ });
+
+ integration("warns about overridden dependencies", () {
+ servePackages([
+ packageMap("foo", "1.0.0"),
+ packageMap("bar", "1.0.0"),
+ packageMap("baz", "1.0.0")
+ ]);
+
+ d.dir(appPath, [
+ d.pubspec({
+ "name": "myapp",
+ "dependency_overrides": {
+ "foo": "any",
+ "bar": "any",
+ "baz": "any"
+ }
+ })
+ ]).create();
+
+ schedulePub(args: [command.name], output: command.success, error:
+ """
+ Warning: You are overriding these dependencies:
+ - bar any from hosted (bar)
+ - baz any from hosted (baz)
+ - foo any from hosted (foo)
+ """);
+ });
+ });
+}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/validator/dependency_override.dart ('k') | sdk/lib/_internal/pub/test/pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine