| OLD | NEW |
| 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 import 'package:path/path.dart' as path; | 5 import 'package:path/path.dart' as path; |
| 6 | 6 |
| 7 import 'descriptor.dart' as d; | 7 import 'descriptor.dart' as d; |
| 8 import 'test_pub.dart'; | 8 import 'test_pub.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 initConfig(); | 11 initConfig(); |
| 12 forBothPubGetAndUpgrade((command) { | 12 forBothPubGetAndUpgrade((command) { |
| 13 integration("chooses best version matching override constraint", () { | 13 integration("chooses best version matching override constraint", () { |
| 14 servePackages((builder) { | 14 servePackages((builder) { |
| 15 builder.serve("foo", "1.0.0"); | 15 builder.serve("foo", "1.0.0"); |
| 16 builder.serve("foo", "2.0.0"); | 16 builder.serve("foo", "2.0.0"); |
| 17 builder.serve("foo", "3.0.0"); | 17 builder.serve("foo", "3.0.0"); |
| 18 }); | 18 }); |
| 19 | 19 |
| 20 d.dir(appPath, [ | 20 d.dir(appPath, [d.pubspec({ |
| 21 d.pubspec({ | |
| 22 "name": "myapp", | 21 "name": "myapp", |
| 23 "dependencies": { | 22 "dependencies": { |
| 24 "foo": ">2.0.0" | 23 "foo": ">2.0.0" |
| 25 }, | 24 }, |
| 26 "dependency_overrides": { | 25 "dependency_overrides": { |
| 27 "foo": "<3.0.0" | 26 "foo": "<3.0.0" |
| 28 } | 27 } |
| 29 }) | 28 })]).create(); |
| 30 ]).create(); | |
| 31 | 29 |
| 32 pubCommand(command); | 30 pubCommand(command); |
| 33 | 31 |
| 34 d.packagesDir({ | 32 d.packagesDir({ |
| 35 "foo": "2.0.0" | 33 "foo": "2.0.0" |
| 36 }).validate(); | 34 }).validate(); |
| 37 }); | 35 }); |
| 38 | 36 |
| 39 integration("treats override as implicit dependency", () { | 37 integration("treats override as implicit dependency", () { |
| 40 servePackages((builder) { | 38 servePackages((builder) { |
| 41 builder.serve("foo", "1.0.0"); | 39 builder.serve("foo", "1.0.0"); |
| 42 }); | 40 }); |
| 43 | 41 |
| 44 d.dir(appPath, [ | 42 d.dir(appPath, [d.pubspec({ |
| 45 d.pubspec({ | |
| 46 "name": "myapp", | 43 "name": "myapp", |
| 47 "dependency_overrides": { | 44 "dependency_overrides": { |
| 48 "foo": "any" | 45 "foo": "any" |
| 49 } | 46 } |
| 50 }) | 47 })]).create(); |
| 51 ]).create(); | |
| 52 | 48 |
| 53 pubCommand(command); | 49 pubCommand(command); |
| 54 | 50 |
| 55 d.packagesDir({ | 51 d.packagesDir({ |
| 56 "foo": "1.0.0" | 52 "foo": "1.0.0" |
| 57 }).validate(); | 53 }).validate(); |
| 58 }); | 54 }); |
| 59 | 55 |
| 60 integration("ignores other constraints on overridden package", () { | 56 integration("ignores other constraints on overridden package", () { |
| 61 servePackages((builder) { | 57 servePackages((builder) { |
| 62 builder.serve("foo", "1.0.0"); | 58 builder.serve("foo", "1.0.0"); |
| 63 builder.serve("foo", "2.0.0"); | 59 builder.serve("foo", "2.0.0"); |
| 64 builder.serve("foo", "3.0.0"); | 60 builder.serve("foo", "3.0.0"); |
| 65 builder.serve("bar", "1.0.0", pubspec: { | 61 builder.serve("bar", "1.0.0", pubspec: { |
| 66 "dependencies": {"foo": "5.0.0-nonexistent"} | 62 "dependencies": { |
| 63 "foo": "5.0.0-nonexistent" |
| 64 } |
| 67 }); | 65 }); |
| 68 }); | 66 }); |
| 69 | 67 |
| 70 d.dir(appPath, [ | 68 d.dir(appPath, [d.pubspec({ |
| 71 d.pubspec({ | |
| 72 "name": "myapp", | 69 "name": "myapp", |
| 73 "dependencies": { | 70 "dependencies": { |
| 74 "bar": "any" | 71 "bar": "any" |
| 75 }, | 72 }, |
| 76 "dependency_overrides": { | 73 "dependency_overrides": { |
| 77 "foo": "<3.0.0" | 74 "foo": "<3.0.0" |
| 78 } | 75 } |
| 79 }) | 76 })]).create(); |
| 80 ]).create(); | |
| 81 | 77 |
| 82 pubCommand(command); | 78 pubCommand(command); |
| 83 | 79 |
| 84 d.packagesDir({ | 80 d.packagesDir({ |
| 85 "foo": "2.0.0", | 81 "foo": "2.0.0", |
| 86 "bar": "1.0.0" | 82 "bar": "1.0.0" |
| 87 }).validate(); | 83 }).validate(); |
| 88 }); | 84 }); |
| 89 | 85 |
| 90 integration("warns about overridden dependencies", () { | 86 integration("warns about overridden dependencies", () { |
| 91 servePackages((builder) { | 87 servePackages((builder) { |
| 92 builder.serve("foo", "1.0.0"); | 88 builder.serve("foo", "1.0.0"); |
| 93 builder.serve("bar", "1.0.0"); | 89 builder.serve("bar", "1.0.0"); |
| 94 }); | 90 }); |
| 95 | 91 |
| 96 d.dir("baz", [ | 92 d.dir("baz", [d.libDir("baz"), d.libPubspec("baz", "0.0.1")]).create(); |
| 97 d.libDir("baz"), | |
| 98 d.libPubspec("baz", "0.0.1") | |
| 99 ]).create(); | |
| 100 | 93 |
| 101 d.dir(appPath, [ | 94 d.dir(appPath, [d.pubspec({ |
| 102 d.pubspec({ | |
| 103 "name": "myapp", | 95 "name": "myapp", |
| 104 "dependency_overrides": { | 96 "dependency_overrides": { |
| 105 "foo": "any", | 97 "foo": "any", |
| 106 "bar": "any", | 98 "bar": "any", |
| 107 "baz": {"path": "../baz"} | 99 "baz": { |
| 100 "path": "../baz" |
| 101 } |
| 108 } | 102 } |
| 109 }) | 103 })]).create(); |
| 110 ]).create(); | |
| 111 | 104 |
| 112 var bazPath = path.join("..", "baz"); | 105 var bazPath = path.join("..", "baz"); |
| 113 | 106 |
| 114 schedulePub(args: [command.name], output: command.success, error: | 107 schedulePub(args: [command.name], output: command.success, error: """ |
| 115 """ | |
| 116 Warning: You are using these overridden dependencies: | 108 Warning: You are using these overridden dependencies: |
| 117 ! bar 1.0.0 | 109 ! bar 1.0.0 |
| 118 ! baz 0.0.1 from path $bazPath | 110 ! baz 0.0.1 from path $bazPath |
| 119 ! foo 1.0.0 | 111 ! foo 1.0.0 |
| 120 """); | 112 """); |
| 121 }); | 113 }); |
| 122 }); | 114 }); |
| 123 } | 115 } |
| OLD | NEW |