OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 #library('pub_tests'); | |
6 | |
7 #import('dart:io'); | |
8 | |
9 #import('test_pub.dart'); | |
10 #import('../../../pkg/unittest/unittest.dart'); | |
11 | |
12 main() { | |
13 test('checks out a package from a pub server', () { | |
14 servePackages([package("foo", "1.2.3")]); | |
15 | |
16 appDir([dependency("foo", "1.2.3")]).scheduleCreate(); | |
17 | |
18 schedulePub(args: ['install'], | |
19 output: const RegExp("Dependencies installed!\$")); | |
20 | |
21 cacheDir({"foo": "1.2.3"}).scheduleValidate(); | |
22 packagesDir({"foo": "1.2.3"}).scheduleValidate(); | |
23 | |
24 run(); | |
25 }); | |
26 | |
27 test('checks out packages transitively from a pub server', () { | |
28 servePackages([ | |
29 package("foo", "1.2.3", [dependency("bar", "2.0.4")]), | |
30 package("bar", "2.0.3"), | |
31 package("bar", "2.0.4"), | |
32 package("bar", "2.0.5") | |
33 ]); | |
34 | |
35 appDir([dependency("foo", "1.2.3")]).scheduleCreate(); | |
36 | |
37 schedulePub(args: ['install'], | |
38 output: const RegExp("Dependencies installed!\$")); | |
39 | |
40 cacheDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate(); | |
41 packagesDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate(); | |
42 | |
43 run(); | |
44 }); | |
45 | |
46 test('resolves version constraints from a pub server', () { | |
47 servePackages([ | |
48 package("foo", "1.2.3", [dependency("baz", ">=2.0.0")]), | |
49 package("bar", "2.3.4", [dependency("baz", "<3.0.0")]), | |
50 package("baz", "2.0.3"), | |
51 package("baz", "2.0.4"), | |
52 package("baz", "3.0.1") | |
53 ]); | |
54 | |
55 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
56 | |
57 schedulePub(args: ['install'], | |
58 output: const RegExp("Dependencies installed!\$")); | |
59 | |
60 cacheDir({ | |
61 "foo": "1.2.3", | |
62 "bar": "2.3.4", | |
63 "baz": "2.0.4" | |
64 }).scheduleValidate(); | |
65 | |
66 packagesDir({ | |
67 "foo": "1.2.3", | |
68 "bar": "2.3.4", | |
69 "baz": "2.0.4" | |
70 }).scheduleValidate(); | |
71 | |
72 run(); | |
73 }); | |
74 | |
75 test('keeps a pub server package locked to the version in the lockfile', () { | |
76 servePackages([package("foo", "1.0.0")]); | |
77 | |
78 appDir([dependency("foo")]).scheduleCreate(); | |
79 | |
80 // This install should lock the foo dependency to version 1.0.0. | |
81 schedulePub(args: ['install'], | |
82 output: const RegExp(@"Dependencies installed!$")); | |
83 | |
84 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
85 | |
86 // Delete the packages path to simulate a new checkout of the application. | |
87 dir(packagesPath).scheduleDelete(); | |
88 | |
89 // Start serving a newer package as well. | |
90 servePackages([package("foo", "1.0.1")]); | |
91 | |
92 // This install shouldn't update the foo dependency due to the lockfile. | |
93 schedulePub(args: ['install'], | |
94 output: const RegExp(@"Dependencies installed!$")); | |
95 | |
96 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
97 | |
98 run(); | |
99 }); | |
100 | |
101 test('updates a locked pub server package with a new incompatible ' | |
102 'constraint', () { | |
103 servePackages([package("foo", "1.0.0")]); | |
104 | |
105 appDir([dependency("foo")]).scheduleCreate(); | |
106 | |
107 schedulePub(args: ['install'], | |
108 output: const RegExp(@"Dependencies installed!$")); | |
109 | |
110 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
111 | |
112 servePackages([package("foo", "1.0.1")]); | |
113 | |
114 appDir([dependency("foo", ">1.0.0")]).scheduleCreate(); | |
115 | |
116 schedulePub(args: ['install'], | |
117 output: const RegExp(@"Dependencies installed!$")); | |
118 | |
119 packagesDir({"foo": "1.0.1"}).scheduleValidate(); | |
120 | |
121 run(); | |
122 }); | |
123 | |
124 test("doesn't update a locked pub server package with a new compatible " | |
125 "constraint", () { | |
126 servePackages([package("foo", "1.0.0")]); | |
127 | |
128 appDir([dependency("foo")]).scheduleCreate(); | |
129 | |
130 schedulePub(args: ['install'], | |
131 output: const RegExp(@"Dependencies installed!$")); | |
132 | |
133 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
134 | |
135 servePackages([package("foo", "1.0.1")]); | |
136 | |
137 appDir([dependency("foo", ">=1.0.0")]).scheduleCreate(); | |
138 | |
139 schedulePub(args: ['install'], | |
140 output: const RegExp(@"Dependencies installed!$")); | |
141 | |
142 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
143 | |
144 run(); | |
145 }); | |
146 | |
147 test("unlocks dependencies if necessary to ensure that a new dependency " | |
148 "is satisfied", () { | |
149 servePackages([ | |
150 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
151 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]), | |
152 package("baz", "1.0.0", [dependency("qux", "<2.0.0")]), | |
153 package("qux", "1.0.0") | |
154 ]); | |
155 | |
156 appDir([dependency("foo")]).scheduleCreate(); | |
157 | |
158 schedulePub(args: ['install'], | |
159 output: const RegExp(@"Dependencies installed!$")); | |
160 | |
161 packagesDir({ | |
162 "foo": "1.0.0", | |
163 "bar": "1.0.0", | |
164 "baz": "1.0.0", | |
165 "qux": "1.0.0" | |
166 }).scheduleValidate(); | |
167 | |
168 servePackages([ | |
169 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
170 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]), | |
171 package("baz", "2.0.0", [dependency("qux", "<3.0.0")]), | |
172 package("qux", "2.0.0"), | |
173 package("newdep", "2.0.0", [dependency("baz", ">=1.5.0")]) | |
174 ]); | |
175 | |
176 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate(); | |
177 | |
178 schedulePub(args: ['install'], | |
179 output: const RegExp(@"Dependencies installed!$")); | |
180 | |
181 packagesDir({ | |
182 "foo": "2.0.0", | |
183 "bar": "2.0.0", | |
184 "baz": "2.0.0", | |
185 "qux": "1.0.0", | |
186 "newdep": "2.0.0" | |
187 }).scheduleValidate(); | |
188 | |
189 run(); | |
190 }); | |
191 | |
192 test("doesn't unlock dependencies if a new dependency is already " | |
193 "satisfied", () { | |
194 servePackages([ | |
195 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
196 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]), | |
197 package("baz", "1.0.0") | |
198 ]); | |
199 | |
200 appDir([dependency("foo")]).scheduleCreate(); | |
201 | |
202 schedulePub(args: ['install'], | |
203 output: const RegExp(@"Dependencies installed!$")); | |
204 | |
205 packagesDir({ | |
206 "foo": "1.0.0", | |
207 "bar": "1.0.0", | |
208 "baz": "1.0.0" | |
209 }).scheduleValidate(); | |
210 | |
211 servePackages([ | |
212 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
213 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]), | |
214 package("baz", "2.0.0"), | |
215 package("newdep", "2.0.0", [dependency("baz", ">=1.0.0")]) | |
216 ]); | |
217 | |
218 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate(); | |
219 | |
220 schedulePub(args: ['install'], | |
221 output: const RegExp(@"Dependencies installed!$")); | |
222 | |
223 packagesDir({ | |
224 "foo": "1.0.0", | |
225 "bar": "1.0.0", | |
226 "baz": "1.0.0", | |
227 "newdep": "2.0.0" | |
228 }).scheduleValidate(); | |
229 | |
230 run(); | |
231 }); | |
232 | |
233 test("removes a dependency that's been removed from the pubspec", () { | |
234 servePackages([ | |
235 package("foo", "1.0.0"), | |
236 package("bar", "1.0.0") | |
237 ]); | |
238 | |
239 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
240 | |
241 schedulePub(args: ['install'], | |
242 output: const RegExp(@"Dependencies installed!$")); | |
243 | |
244 packagesDir({ | |
245 "foo": "1.0.0", | |
246 "bar": "1.0.0" | |
247 }).scheduleValidate(); | |
248 | |
249 appDir([dependency("foo")]).scheduleCreate(); | |
250 | |
251 schedulePub(args: ['install'], | |
252 output: const RegExp(@"Dependencies installed!$")); | |
253 | |
254 packagesDir({ | |
255 "foo": "1.0.0", | |
256 "bar": null | |
257 }).scheduleValidate(); | |
258 | |
259 run(); | |
260 }); | |
261 | |
262 test("removes a transitive dependency that's no longer depended on", () { | |
263 servePackages([ | |
264 package("foo", "1.0.0", [dependency("shared-dep")]), | |
265 package("bar", "1.0.0", [ | |
266 dependency("shared-dep"), | |
267 dependency("bar-dep") | |
268 ]), | |
269 package("shared-dep", "1.0.0"), | |
270 package("bar-dep", "1.0.0") | |
271 ]); | |
272 | |
273 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
274 | |
275 schedulePub(args: ['install'], | |
276 output: const RegExp(@"Dependencies installed!$")); | |
277 | |
278 packagesDir({ | |
279 "foo": "1.0.0", | |
280 "bar": "1.0.0", | |
281 "shared-dep": "1.0.0", | |
282 "bar-dep": "1.0.0", | |
283 }).scheduleValidate(); | |
284 | |
285 appDir([dependency("foo")]).scheduleCreate(); | |
286 | |
287 schedulePub(args: ['install'], | |
288 output: const RegExp(@"Dependencies installed!$")); | |
289 | |
290 packagesDir({ | |
291 "foo": "1.0.0", | |
292 "bar": null, | |
293 "shared-dep": "1.0.0", | |
294 "bar-dep": null, | |
295 }).scheduleValidate(); | |
296 | |
297 run(); | |
298 }); | |
299 | |
300 test("doesn't update dependencies whose constraints have been removed", () { | |
301 servePackages([ | |
302 package("foo", "1.0.0", [dependency("shared-dep")]), | |
303 package("bar", "1.0.0", [dependency("shared-dep", "<2.0.0")]), | |
304 package("shared-dep", "1.0.0"), | |
305 package("shared-dep", "2.0.0") | |
306 ]); | |
307 | |
308 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
309 | |
310 schedulePub(args: ['install'], | |
311 output: const RegExp(@"Dependencies installed!$")); | |
312 | |
313 packagesDir({ | |
314 "foo": "1.0.0", | |
315 "bar": "1.0.0", | |
316 "shared-dep": "1.0.0" | |
317 }).scheduleValidate(); | |
318 | |
319 appDir([dependency("foo")]).scheduleCreate(); | |
320 | |
321 schedulePub(args: ['install'], | |
322 output: const RegExp(@"Dependencies installed!$")); | |
323 | |
324 packagesDir({ | |
325 "foo": "1.0.0", | |
326 "bar": null, | |
327 "shared-dep": "1.0.0" | |
328 }).scheduleValidate(); | |
329 | |
330 run(); | |
331 }); | |
332 } | |
OLD | NEW |