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