Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: utils/tests/pub/pub_test.dart

Issue 10871008: Add a number of convenience methods to test_pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | utils/tests/pub/test_pub.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 #library('pub_tests'); 5 #library('pub_tests');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 8
9 #import('test_pub.dart'); 9 #import('test_pub.dart');
10 #import('../../../pkg/unittest/unittest.dart'); 10 #import('../../../pkg/unittest/unittest.dart');
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 '''); 86 ''');
87 }); 87 });
88 }); 88 });
89 */ 89 */
90 } 90 }
91 91
92 installCommand() { 92 installCommand() {
93 test('checks out a package from the SDK', () { 93 test('checks out a package from the SDK', () {
94 dir(sdkPath, [ 94 dir(sdkPath, [
95 file('revision', '1234'), 95 file('revision', '1234'),
96 dir('pkg', [ 96 dir('pkg', [packageDir("foo", "0.0.1234")])
97 dir('foo', [
98 file('foo.dart', 'main() => "foo";')
99 ])
100 ])
101 ]).scheduleCreate(); 97 ]).scheduleCreate();
102 98
103 dir(appPath, [ 99 dir(appPath, [
104 file('pubspec.yaml', 'dependencies:\n foo:') 100 pubspec({"dependencies": {"foo": null}})
105 ]).scheduleCreate(); 101 ]).scheduleCreate();
106 102
107 schedulePub(args: ['install'], 103 schedulePub(args: ['install'],
108 output: ''' 104 output: '''
109 Dependencies installed! 105 Dependencies installed!
110 '''); 106 ''');
111 107
112 dir(packagesPath, [ 108 packagesDir({"foo": "0.0.1234"}).scheduleValidate();
113 dir('foo', [
114 file('foo.dart', 'main() => "foo";')
115 ])
116 ]).scheduleValidate();
117 109
118 run(); 110 run();
119 }); 111 });
120 112
121 test('checks out a package from Git', () { 113 test('checks out a package from Git', () {
122 ensureGit(); 114 ensureGit();
123 115
124 git('foo.git', [ 116 git('foo.git', [
125 file('foo.dart', 'main() => "foo";') 117 file('foo.dart', 'main() => "foo";')
126 ]).scheduleCreate(); 118 ]).scheduleCreate();
127 119
128 dir(appPath, [ 120 appDir([{"git": "../foo.git"}]).scheduleCreate();
129 file('pubspec.yaml', '''
130 dependencies:
131 foo:
132 git: ../foo.git
133 ''')
134 ]).scheduleCreate();
135 121
136 schedulePub(args: ['install'], 122 schedulePub(args: ['install'],
137 output: const RegExp(@"Dependencies installed!$")); 123 output: const RegExp(@"Dependencies installed!$"));
138 124
139 dir(cachePath, [ 125 dir(cachePath, [
140 dir('git', [ 126 dir('git', [
141 dir('cache', [ 127 dir('cache', [gitPackageCacheDir('foo')]),
142 dir(new RegExp(@'foo-[a-f0-9]+'), [ 128 gitPackageCacheDir('foo')
143 file('foo.dart', 'main() => "foo";')
144 ])
145 ]),
146 dir(new RegExp(@'foo-[a-f0-9]+'), [
147 file('foo.dart', 'main() => "foo";')
148 ])
149 ]) 129 ])
150 ]).scheduleValidate(); 130 ]).scheduleValidate();
151 131
152 dir(packagesPath, [ 132 dir(packagesPath, [
153 dir('foo', [ 133 dir('foo', [
154 file('foo.dart', 'main() => "foo";') 134 file('foo.dart', 'main() => "foo";')
155 ]) 135 ])
156 ]).scheduleValidate(); 136 ]).scheduleValidate();
157 137
158 run(); 138 run();
159 }); 139 });
160 140
161 test('checks out packages transitively from Git', () { 141 test('checks out packages transitively from Git', () {
162 ensureGit(); 142 ensureGit();
163 143
164 git('foo.git', [ 144 git('foo.git', [
165 file('foo.dart', 'main() => "foo";'), 145 file('foo.dart', 'main() => "foo";'),
166 file('pubspec.yaml', ''' 146 appPubspec([{"git": "../bar.git"}])
167 dependencies:
168 bar:
169 git: ../bar.git
170 ''')
171 ]).scheduleCreate(); 147 ]).scheduleCreate();
172 148
173 git('bar.git', [ 149 git('bar.git', [
174 file('bar.dart', 'main() => "bar";') 150 file('bar.dart', 'main() => "bar";')
175 ]).scheduleCreate(); 151 ]).scheduleCreate();
176 152
177 dir(appPath, [ 153 appDir([{"git": "../foo.git"}]).scheduleCreate();
178 file('pubspec.yaml', '''
179 dependencies:
180 foo:
181 git: ../foo.git
182 ''')
183 ]).scheduleCreate();
184 154
185 schedulePub(args: ['install'], 155 schedulePub(args: ['install'],
186 output: const RegExp("Dependencies installed!\$")); 156 output: const RegExp("Dependencies installed!\$"));
187 157
188 dir(cachePath, [ 158 dir(cachePath, [
189 dir('git', [ 159 dir('git', [
190 dir('cache', [ 160 dir('cache', [
191 dir(new RegExp(@'foo-[a-f0-9]+'), [ 161 gitPackageCacheDir('foo'),
192 file('foo.dart', 'main() => "foo";') 162 gitPackageCacheDir('bar')
193 ]),
194 dir(new RegExp(@'bar-[a-f0-9]+'), [
195 file('bar.dart', 'main() => "bar";')
196 ])
197 ]), 163 ]),
198 dir(new RegExp(@'foo-[a-f0-9]+'), [ 164 gitPackageCacheDir('foo'),
199 file('foo.dart', 'main() => "foo";') 165 gitPackageCacheDir('bar')
200 ]),
201 dir(new RegExp(@'bar-[a-f0-9]+'), [
202 file('bar.dart', 'main() => "bar";')
203 ])
204 ]) 166 ])
205 ]).scheduleValidate(); 167 ]).scheduleValidate();
206 168
207 dir(packagesPath, [ 169 dir(packagesPath, [
208 dir('foo', [ 170 dir('foo', [
209 file('foo.dart', 'main() => "foo";') 171 file('foo.dart', 'main() => "foo";')
210 ]), 172 ]),
211 dir('bar', [ 173 dir('bar', [
212 file('bar.dart', 'main() => "bar";') 174 file('bar.dart', 'main() => "bar";')
213 ]) 175 ])
214 ]).scheduleValidate(); 176 ]).scheduleValidate();
215 177
216 run(); 178 run();
217 }); 179 });
218 180
219 test('checks out and updates a package from Git', () { 181 test('checks out and updates a package from Git', () {
220 ensureGit(); 182 ensureGit();
221 183
222 git('foo.git', [ 184 git('foo.git', [
223 file('foo.dart', 'main() => "foo";') 185 file('foo.dart', 'main() => "foo";')
224 ]).scheduleCreate(); 186 ]).scheduleCreate();
225 187
226 dir(appPath, [ 188 appDir([{"git": "../foo.git"}]).scheduleCreate();
227 file('pubspec.yaml', '''
228 dependencies:
229 foo:
230 git: ../foo.git
231 ''')
232 ]).scheduleCreate();
233 189
234 schedulePub(args: ['install'], 190 schedulePub(args: ['install'],
235 output: const RegExp(@"Dependencies installed!$")); 191 output: const RegExp(@"Dependencies installed!$"));
236 192
237 dir(cachePath, [ 193 dir(cachePath, [
238 dir('git', [ 194 dir('git', [
239 dir('cache', [ 195 dir('cache', [gitPackageCacheDir('foo')]),
240 dir(new RegExp(@'foo-[a-f0-9]+'), [ 196 gitPackageCacheDir('foo')
241 file('foo.dart', 'main() => "foo";')
242 ])
243 ]),
244 dir(new RegExp(@'foo-[a-f0-9]+'), [
245 file('foo.dart', 'main() => "foo";')
246 ])
247 ]) 197 ])
248 ]).scheduleValidate(); 198 ]).scheduleValidate();
249 199
250 dir(packagesPath, [ 200 dir(packagesPath, [
251 dir('foo', [ 201 dir('foo', [
252 file('foo.dart', 'main() => "foo";') 202 file('foo.dart', 'main() => "foo";')
253 ]) 203 ])
254 ]).scheduleValidate(); 204 ]).scheduleValidate();
255 205
256 // TODO(nweiz): remove this once we support pub update 206 // TODO(nweiz): remove this once we support pub update
257 dir(packagesPath).scheduleDelete(); 207 dir(packagesPath).scheduleDelete();
258 file('$appPath/pubspec.lock', '').scheduleDelete(); 208 file('$appPath/pubspec.lock', '').scheduleDelete();
259 209
260 git('foo.git', [ 210 git('foo.git', [
261 file('foo.dart', 'main() => "foo 2";') 211 file('foo.dart', 'main() => "foo 2";')
262 ]).scheduleCommit(); 212 ]).scheduleCommit();
263 213
264 schedulePub(args: ['install'], 214 schedulePub(args: ['install'],
265 output: const RegExp(@"Dependencies installed!$")); 215 output: const RegExp(@"Dependencies installed!$"));
266 216
267 // When we download a new version of the git package, we should re-use the 217 // When we download a new version of the git package, we should re-use the
268 // git/cache directory but create a new git/ directory. 218 // git/cache directory but create a new git/ directory.
269 dir(cachePath, [ 219 dir(cachePath, [
270 dir('git', [ 220 dir('git', [
271 dir('cache', [ 221 dir('cache', [gitPackageCacheDir('foo', 2)]),
272 dir(new RegExp(@'foo-[a-f0-9]+'), [ 222 gitPackageCacheDir('foo'),
273 file('foo.dart', 'main() => "foo 2";') 223 gitPackageCacheDir('foo', 2)
274 ])
275 ]),
276 dir(new RegExp(@'foo-[a-f0-9]+'), [
277 file('foo.dart', 'main() => "foo";')
278 ]),
279 dir(new RegExp(@'foo-[a-f0-9]+'), [
280 file('foo.dart', 'main() => "foo 2";')
281 ])
282 ]) 224 ])
283 ]).scheduleValidate(); 225 ]).scheduleValidate();
284 226
285 dir(packagesPath, [ 227 dir(packagesPath, [
286 dir('foo', [ 228 dir('foo', [
287 file('foo.dart', 'main() => "foo 2";') 229 file('foo.dart', 'main() => "foo 2";')
288 ]) 230 ])
289 ]).scheduleValidate(); 231 ]).scheduleValidate();
290 232
291 run(); 233 run();
292 }); 234 });
293 235
294 test('checks out a package from Git twice', () { 236 test('checks out a package from Git twice', () {
295 ensureGit(); 237 ensureGit();
296 238
297 git('foo.git', [ 239 git('foo.git', [
298 file('foo.dart', 'main() => "foo";') 240 file('foo.dart', 'main() => "foo";')
299 ]).scheduleCreate(); 241 ]).scheduleCreate();
300 242
301 dir(appPath, [ 243 appDir([{"git": "../foo.git"}]).scheduleCreate();
302 file('pubspec.yaml', '''
303 dependencies:
304 foo:
305 git: ../foo.git
306 ''')
307 ]).scheduleCreate();
308 244
309 schedulePub(args: ['install'], 245 schedulePub(args: ['install'],
310 output: const RegExp(@"Dependencies installed!$")); 246 output: const RegExp(@"Dependencies installed!$"));
311 247
312 dir(cachePath, [ 248 dir(cachePath, [
313 dir('git', [ 249 dir('git', [
314 dir('cache', [ 250 dir('cache', [gitPackageCacheDir('foo')]),
315 dir(new RegExp(@'foo-[a-f0-9]+'), [ 251 gitPackageCacheDir('foo')
316 file('foo.dart', 'main() => "foo";')
317 ])
318 ]),
319 dir(new RegExp(@'foo-[a-f0-9]+'), [
320 file('foo.dart', 'main() => "foo";')
321 ])
322 ]) 252 ])
323 ]).scheduleValidate(); 253 ]).scheduleValidate();
324 254
325 dir(packagesPath, [ 255 dir(packagesPath, [
326 dir('foo', [ 256 dir('foo', [
327 file('foo.dart', 'main() => "foo";') 257 file('foo.dart', 'main() => "foo";')
328 ]) 258 ])
329 ]).scheduleValidate(); 259 ]).scheduleValidate();
330 260
331 // TODO(nweiz): remove this once we support pub update 261 // TODO(nweiz): remove this once we support pub update
332 dir(packagesPath).scheduleDelete(); 262 dir(packagesPath).scheduleDelete();
333 263
334 // Verify that nothing breaks if we install a Git revision that's already 264 // Verify that nothing breaks if we install a Git revision that's already
335 // in the cache. 265 // in the cache.
336 schedulePub(args: ['install'], 266 schedulePub(args: ['install'],
337 output: const RegExp(@"Dependencies installed!$")); 267 output: const RegExp(@"Dependencies installed!$"));
338 268
339 run(); 269 run();
340 }); 270 });
341 271
342 test('checks out a package at a specific revision from Git', () { 272 test('checks out a package at a specific revision from Git', () {
343 ensureGit(); 273 ensureGit();
344 274
345 var repo = git('foo.git', [ 275 var repo = git('foo.git', [
346 file('foo.dart', 'main() => "foo 1";') 276 file('foo.dart', 'main() => "foo 1";')
347 ]); 277 ]);
348 repo.scheduleCreate(); 278 repo.scheduleCreate();
349 var commitFuture = repo.revParse('HEAD'); 279 var commit = repo.revParse('HEAD');
350 280
351 git('foo.git', [ 281 git('foo.git', [
352 file('foo.dart', 'main() => "foo 2";') 282 file('foo.dart', 'main() => "foo 2";')
353 ]).scheduleCommit(); 283 ]).scheduleCommit();
354 284
355 dir(appPath, [ 285 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate();
356 async(commitFuture.transform((commit) {
357 return file('pubspec.yaml', '''
358 dependencies:
359 foo:
360 git:
361 url: ../foo.git
362 ref: $commit
363 ''');
364 }))
365 ]).scheduleCreate();
366 286
367 schedulePub(args: ['install'], 287 schedulePub(args: ['install'],
368 output: const RegExp(@"Dependencies installed!$")); 288 output: const RegExp(@"Dependencies installed!$"));
369 289
370 dir(packagesPath, [ 290 dir(packagesPath, [
371 dir('foo', [ 291 dir('foo', [
372 file('foo.dart', 'main() => "foo 1";') 292 file('foo.dart', 'main() => "foo 1";')
373 ]) 293 ])
374 ]).scheduleValidate(); 294 ]).scheduleValidate();
375 295
376 run(); 296 run();
377 }); 297 });
378 298
379 test('checks out a package from a pub server', () { 299 test('checks out a package from a pub server', () {
380 servePackages("localhost", 3123, ['{name: foo, version: 1.2.3}']); 300 servePackages("localhost", 3123, [package("foo", "1.2.3")]);
381 301
382 dir(appPath, [ 302 appDir([dependency("foo", "1.2.3")]).scheduleCreate();
383 file('pubspec.yaml', '''
384 dependencies:
385 foo:
386 repo:
387 name: foo
388 url: http://localhost:3123
389 version: 1.2.3
390 ''')
391 ]).scheduleCreate();
392 303
393 schedulePub(args: ['install'], 304 schedulePub(args: ['install'],
394 output: const RegExp("Dependencies installed!\$")); 305 output: const RegExp("Dependencies installed!\$"));
395 306
396 dir(cachePath, [ 307 cacheDir({"foo": "1.2.3"}).scheduleValidate();
397 dir('repo', [ 308 packagesDir({"foo": "1.2.3"}).scheduleValidate();
398 dir('localhost%583123', [
399 dir('foo-1.2.3', [
400 file('pubspec.yaml', '{name: foo, version: 1.2.3}'),
401 file('foo.dart', 'main() => print("foo 1.2.3");')
402 ])
403 ])
404 ])
405 ]).scheduleValidate();
406
407 dir(packagesPath, [
408 dir('foo', [
409 file('pubspec.yaml', '{name: foo, version: 1.2.3}'),
410 file('foo.dart', 'main() => print("foo 1.2.3");')
411 ])
412 ]).scheduleValidate();
413 309
414 run(); 310 run();
415 }); 311 });
416 312
417 test('checks out packages transitively from a pub server', () { 313 test('checks out packages transitively from a pub server', () {
418 servePackages("localhost", 3123, [ 314 servePackages("localhost", 3123, [
419 ''' 315 package("foo", "1.2.3", [dependency("bar", "2.0.4")]),
420 name: foo 316 package("bar", "2.0.3"),
421 version: 1.2.3 317 package("bar", "2.0.4"),
422 dependencies: 318 package("bar", "2.0.5")
423 bar:
424 repo: {name: bar, url: http://localhost:3123}
425 version: 2.0.4
426 ''',
427 '{name: bar, version: 2.0.3}',
428 '{name: bar, version: 2.0.4}',
429 '{name: bar, version: 2.0.5}',
430 ]); 319 ]);
431 320
432 dir(appPath, [ 321 appDir([dependency("foo", "1.2.3")]).scheduleCreate();
433 file('pubspec.yaml', '''
434 dependencies:
435 foo:
436 repo:
437 name: foo
438 url: http://localhost:3123
439 version: 1.2.3
440 ''')
441 ]).scheduleCreate();
442 322
443 schedulePub(args: ['install'], 323 schedulePub(args: ['install'],
444 output: const RegExp("Dependencies installed!\$")); 324 output: const RegExp("Dependencies installed!\$"));
445 325
446 dir(cachePath, [ 326 cacheDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate();
447 dir('repo', [ 327 packagesDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate();
448 dir('localhost%583123', [
449 dir('foo-1.2.3', [
450 file('pubspec.yaml', '''
451 name: foo
452 version: 1.2.3
453 dependencies:
454 bar:
455 repo: {name: bar, url: http://localhost:3123}
456 version: 2.0.4
457 '''),
458 file('foo.dart', 'main() => print("foo 1.2.3");')
459 ]),
460 dir('bar-2.0.4', [
461 file('pubspec.yaml', '{name: bar, version: 2.0.4}'),
462 file('bar.dart', 'main() => print("bar 2.0.4");')
463 ])
464 ])
465 ])
466 ]).scheduleValidate();
467
468 dir(packagesPath, [
469 dir('foo', [
470 file('pubspec.yaml', '''
471 name: foo
472 version: 1.2.3
473 dependencies:
474 bar:
475 repo: {name: bar, url: http://localhost:3123}
476 version: 2.0.4
477 '''),
478 file('foo.dart', 'main() => print("foo 1.2.3");')
479 ]),
480 dir('bar', [
481 file('pubspec.yaml', '{name: bar, version: 2.0.4}'),
482 file('bar.dart', 'main() => print("bar 2.0.4");')
483 ])
484 ]).scheduleValidate();
485 328
486 run(); 329 run();
487 }); 330 });
488 331
489 test('resolves version constraints from a pub server', () { 332 test('resolves version constraints from a pub server', () {
490 servePackages("localhost", 3123, [ 333 servePackages("localhost", 3123, [
491 ''' 334 package("foo", "1.2.3", [dependency("baz", ">=2.0.0")]),
492 name: foo 335 package("bar", "2.3.4", [dependency("baz", "<3.0.0")]),
493 version: 1.2.3 336 package("baz", "2.0.3"),
494 dependencies: 337 package("baz", "2.0.4"),
495 baz: 338 package("baz", "3.0.1")
496 repo: {name: baz, url: http://localhost:3123}
497 version: ">=2.0.0"
498 ''',
499 '''
500 name: bar
501 version: 2.3.4
502 dependencies:
503 baz:
504 repo: {name: baz, url: http://localhost:3123}
505 version: "<3.0.0"
506 ''',
507 '{name: baz, version: 2.0.3}',
508 '{name: baz, version: 2.0.4}',
509 '{name: baz, version: 3.0.1}',
510 ]); 339 ]);
511 340
512 dir(appPath, [ 341 appDir([dependency("foo"), dependency("bar")]).scheduleCreate();
513 file('pubspec.yaml', '''
514 dependencies:
515 foo: {repo: {name: foo, url: http://localhost:3123}}
516 bar: {repo: {name: bar, url: http://localhost:3123}}
517 ''')
518 ]).scheduleCreate();
519 342
520 schedulePub(args: ['install'], 343 schedulePub(args: ['install'],
521 output: const RegExp("Dependencies installed!\$")); 344 output: const RegExp("Dependencies installed!\$"));
522 345
523 dir(cachePath, [ 346 cacheDir({
524 dir('repo', [ 347 "foo": "1.2.3",
525 dir('localhost%583123', [ 348 "bar": "2.3.4",
526 dir('foo-1.2.3', [ 349 "baz": "2.0.4"
527 file('pubspec.yaml', ''' 350 }).scheduleValidate();
528 name: foo
529 version: 1.2.3
530 dependencies:
531 baz:
532 repo: {name: baz, url: http://localhost:3123}
533 version: ">=2.0.0"
534 '''),
535 file('foo.dart', 'main() => print("foo 1.2.3");')
536 ]),
537 dir('bar-2.3.4', [
538 file('pubspec.yaml', '''
539 name: bar
540 version: 2.3.4
541 dependencies:
542 baz:
543 repo: {name: baz, url: http://localhost:3123}
544 version: "<3.0.0"
545 '''),
546 file('bar.dart', 'main() => print("bar 2.3.4");')
547 ]),
548 dir('baz-2.0.4', [
549 file('pubspec.yaml', '{name: baz, version: 2.0.4}'),
550 file('baz.dart', 'main() => print("baz 2.0.4");')
551 ])
552 ])
553 ])
554 ]).scheduleValidate();
555 351
556 dir(packagesPath, [ 352 packagesDir({
557 dir('foo', [ 353 "foo": "1.2.3",
558 file('pubspec.yaml', ''' 354 "bar": "2.3.4",
559 name: foo 355 "baz": "2.0.4"
560 version: 1.2.3 356 }).scheduleValidate();
561 dependencies:
562 baz:
563 repo: {name: baz, url: http://localhost:3123}
564 version: ">=2.0.0"
565 '''),
566 file('foo.dart', 'main() => print("foo 1.2.3");')
567 ]),
568 dir('bar', [
569 file('pubspec.yaml', '''
570 name: bar
571 version: 2.3.4
572 dependencies:
573 baz:
574 repo: {name: baz, url: http://localhost:3123}
575 version: "<3.0.0"
576 '''),
577 file('bar.dart', 'main() => print("bar 2.3.4");')
578 ]),
579 dir('baz', [
580 file('pubspec.yaml', '{name: baz, version: 2.0.4}'),
581 file('baz.dart', 'main() => print("baz 2.0.4");')
582 ])
583 ]).scheduleValidate();
584 357
585 run(); 358 run();
586 }); 359 });
587 360
588 test('keeps a Git package locked to the version in the lockfile', () { 361 test('keeps a Git package locked to the version in the lockfile', () {
589 ensureGit(); 362 ensureGit();
590 363
591 git('foo.git', [ 364 git('foo.git', [
592 file('foo.dart', 'main() => "foo";') 365 file('foo.dart', 'main() => "foo";')
593 ]).scheduleCreate(); 366 ]).scheduleCreate();
594 367
595 dir(appPath, [ 368 appDir([{"git": "../foo.git"}]).scheduleCreate();
596 file('pubspec.yaml', '''
597 dependencies:
598 foo:
599 git: ../foo.git
600 ''')
601 ]).scheduleCreate();
602 369
603 // This install should lock the foo.git dependency to the current revision. 370 // This install should lock the foo.git dependency to the current revision.
604 schedulePub(args: ['install'], 371 schedulePub(args: ['install'],
605 output: const RegExp(@"Dependencies installed!$")); 372 output: const RegExp(@"Dependencies installed!$"));
606 373
607 dir(packagesPath, [ 374 dir(packagesPath, [
608 dir('foo', [ 375 dir('foo', [
609 file('foo.dart', 'main() => "foo";') 376 file('foo.dart', 'main() => "foo";')
610 ]) 377 ])
611 ]).scheduleValidate(); 378 ]).scheduleValidate();
(...skipping 18 matching lines...) Expand all
630 run(); 397 run();
631 }); 398 });
632 399
633 test('updates a locked Git package with a new incompatible constraint', () { 400 test('updates a locked Git package with a new incompatible constraint', () {
634 ensureGit(); 401 ensureGit();
635 402
636 git('foo.git', [ 403 git('foo.git', [
637 file('foo.dart', 'main() => "foo";') 404 file('foo.dart', 'main() => "foo";')
638 ]).scheduleCreate(); 405 ]).scheduleCreate();
639 406
640 dir(appPath, [ 407 appDir([{"git": "../foo.git"}]).scheduleCreate();
641 file('pubspec.yaml', '''
642 dependencies:
643 foo:
644 git: ../foo.git
645 ''')
646 ]).scheduleCreate();
647 408
648 schedulePub(args: ['install'], 409 schedulePub(args: ['install'],
649 output: const RegExp(@"Dependencies installed!$")); 410 output: const RegExp(@"Dependencies installed!$"));
650 411
651 dir(packagesPath, [ 412 dir(packagesPath, [
652 dir('foo', [ 413 dir('foo', [
653 file('foo.dart', 'main() => "foo";') 414 file('foo.dart', 'main() => "foo";')
654 ]) 415 ])
655 ]).scheduleValidate(); 416 ]).scheduleValidate();
656 417
657 git('foo.git', [ 418 git('foo.git', [
658 file('foo.dart', 'main() => "foo 1.0.0";'), 419 file('foo.dart', 'main() => "foo 1.0.0";'),
659 file('pubspec.yaml', 'version: 1.0.0') 420 libPubspec("foo", "1.0.0")
660 ]).scheduleCommit(); 421 ]).scheduleCommit();
661 422
662 dir(appPath, [ 423 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate();
663 file('pubspec.yaml', '''
664 dependencies:
665 foo:
666 git: ../foo.git
667 version: ">=1.0.0"
668 ''')
669 ]).scheduleCreate();
670 424
671 schedulePub(args: ['install'], 425 schedulePub(args: ['install'],
672 output: const RegExp(@"Dependencies installed!$")); 426 output: const RegExp(@"Dependencies installed!$"));
673 427
674 dir(packagesPath, [ 428 dir(packagesPath, [
675 dir('foo', [ 429 dir('foo', [
676 file('foo.dart', 'main() => "foo 1.0.0";') 430 file('foo.dart', 'main() => "foo 1.0.0";')
677 ]) 431 ])
678 ]).scheduleValidate(); 432 ]).scheduleValidate();
679 433
680 run(); 434 run();
681 }); 435 });
682 436
683 test("doesn't update a locked Git package with a new compatible " 437 test("doesn't update a locked Git package with a new compatible "
684 "constraint", () { 438 "constraint", () {
685 ensureGit(); 439 ensureGit();
686 440
687 git('foo.git', [ 441 git('foo.git', [
688 file('foo.dart', 'main() => "foo 1.0.0";'), 442 file('foo.dart', 'main() => "foo 1.0.0";'),
689 file('pubspec.yaml', 'version: 1.0.0') 443 libPubspec("foo", "1.0.0")
690 ]).scheduleCreate(); 444 ]).scheduleCreate();
691 445
692 dir(appPath, [ 446 appDir([{"git": "../foo.git"}]).scheduleCreate();
693 file('pubspec.yaml', '''
694 dependencies:
695 foo:
696 git: ../foo.git
697 ''')
698 ]).scheduleCreate();
699 447
700 schedulePub(args: ['install'], 448 schedulePub(args: ['install'],
701 output: const RegExp(@"Dependencies installed!$")); 449 output: const RegExp(@"Dependencies installed!$"));
702 450
703 dir(packagesPath, [ 451 dir(packagesPath, [
704 dir('foo', [ 452 dir('foo', [
705 file('foo.dart', 'main() => "foo 1.0.0";') 453 file('foo.dart', 'main() => "foo 1.0.0";')
706 ]) 454 ])
707 ]).scheduleValidate(); 455 ]).scheduleValidate();
708 456
709 git('foo.git', [ 457 git('foo.git', [
710 file('foo.dart', 'main() => "foo 1.0.1";'), 458 file('foo.dart', 'main() => "foo 1.0.1";'),
711 file('pubspec.yaml', 'version: 1.0.1') 459 libPubspec("foo", "1.0.1")
712 ]).scheduleCommit(); 460 ]).scheduleCommit();
713 461
714 dir(appPath, [ 462 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate();
715 file('pubspec.yaml', '''
716 dependencies:
717 foo:
718 git: ../foo.git
719 version: ">=1.0.0"
720 ''')
721 ]).scheduleCreate();
722 463
723 schedulePub(args: ['install'], 464 schedulePub(args: ['install'],
724 output: const RegExp(@"Dependencies installed!$")); 465 output: const RegExp(@"Dependencies installed!$"));
725 466
726 dir(packagesPath, [ 467 dir(packagesPath, [
727 dir('foo', [ 468 dir('foo', [
728 file('foo.dart', 'main() => "foo 1.0.0";') 469 file('foo.dart', 'main() => "foo 1.0.0";')
729 ]) 470 ])
730 ]).scheduleValidate(); 471 ]).scheduleValidate();
731 472
732 run(); 473 run();
733 }); 474 });
734 475
735 test('keeps a pub server package locked to the version in the lockfile', () { 476 test('keeps a pub server package locked to the version in the lockfile', () {
736 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); 477 servePackages("localhost", 3123, [package("foo", "1.0.0")]);
737 478
738 dir(appPath, [ 479 appDir([dependency("foo")]).scheduleCreate();
739 file('pubspec.yaml', '''
740 dependencies:
741 foo:
742 repo: {name: foo, url: http://localhost:3123}
743 ''')
744 ]).scheduleCreate();
745 480
746 // This install should lock the foo dependency to version 1.0.0. 481 // This install should lock the foo dependency to version 1.0.0.
747 schedulePub(args: ['install'], 482 schedulePub(args: ['install'],
748 output: const RegExp(@"Dependencies installed!$")); 483 output: const RegExp(@"Dependencies installed!$"));
749 484
750 dir(packagesPath, [ 485 packagesDir({"foo": "1.0.0"}).scheduleValidate();
751 dir('foo', [
752 file('foo.dart', 'main() => print("foo 1.0.0");')
753 ])
754 ]).scheduleValidate();
755 486
756 // Delete the packages path to simulate a new checkout of the application. 487 // Delete the packages path to simulate a new checkout of the application.
757 dir(packagesPath).scheduleDelete(); 488 dir(packagesPath).scheduleDelete();
758 489
759 // Start serving a newer package as well. 490 // Start serving a newer package as well.
760 servePackages("localhost", 3123, [ 491 servePackages("localhost", 3123, [
761 '{name: foo, version: 1.0.0}', 492 package("foo", "1.0.0"),
762 '{name: foo, version: 1.0.1}' 493 package("foo", "1.0.1")
763 ]); 494 ]);
764 495
765 // This install shouldn't update the foo dependency due to the lockfile. 496 // This install shouldn't update the foo dependency due to the lockfile.
766 schedulePub(args: ['install'], 497 schedulePub(args: ['install'],
767 output: const RegExp(@"Dependencies installed!$")); 498 output: const RegExp(@"Dependencies installed!$"));
768 499
769 dir(packagesPath, [ 500 packagesDir({"foo": "1.0.0"}).scheduleValidate();
770 dir('foo', [
771 file('foo.dart', 'main() => print("foo 1.0.0");')
772 ])
773 ]).scheduleValidate();
774 501
775 run(); 502 run();
776 }); 503 });
777 504
778 test('updates a locked pub server package with a new incompatible ' 505 test('updates a locked pub server package with a new incompatible '
779 'constraint', () { 506 'constraint', () {
780 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); 507 servePackages("localhost", 3123, [package("foo", "1.0.0")]);
781 508
782 dir(appPath, [ 509 appDir([dependency("foo")]).scheduleCreate();
783 file('pubspec.yaml', '''
784 dependencies:
785 foo:
786 repo: {name: foo, url: http://localhost:3123}
787 ''')
788 ]).scheduleCreate();
789 510
790 schedulePub(args: ['install'], 511 schedulePub(args: ['install'],
791 output: const RegExp(@"Dependencies installed!$")); 512 output: const RegExp(@"Dependencies installed!$"));
792 513
793 dir(packagesPath, [ 514 packagesDir({"foo": "1.0.0"}).scheduleValidate();
794 dir('foo', [
795 file('foo.dart', 'main() => print("foo 1.0.0");')
796 ])
797 ]).scheduleValidate();
798 515
799 servePackages("localhost", 3123, [ 516 servePackages("localhost", 3123, [
800 '{name: foo, version: 1.0.0}', 517 package("foo", "1.0.0"),
801 '{name: foo, version: 1.0.1}' 518 package("foo", "1.0.1")
802 ]); 519 ]);
803 520
804 dir(appPath, [ 521 appDir([dependency("foo", ">1.0.0")]).scheduleCreate();
805 file('pubspec.yaml', '''
806 dependencies:
807 foo:
808 repo: {name: foo, url: http://localhost:3123}
809 version: ">1.0.0"
810 ''')
811 ]).scheduleCreate();
812 522
813 schedulePub(args: ['install'], 523 schedulePub(args: ['install'],
814 output: const RegExp(@"Dependencies installed!$")); 524 output: const RegExp(@"Dependencies installed!$"));
815 525
816 dir(packagesPath, [ 526 packagesDir({"foo": "1.0.1"}).scheduleValidate();
817 dir('foo', [
818 file('foo.dart', 'main() => print("foo 1.0.1");')
819 ])
820 ]).scheduleValidate();
821 527
822 run(); 528 run();
823 }); 529 });
824 530
825 test("doesn't update a locked pub server package with a new compatible " 531 test("doesn't update a locked pub server package with a new compatible "
826 "constraint", () { 532 "constraint", () {
827 servePackages("localhost", 3123, ['{name: foo, version: 1.0.0}']); 533 servePackages("localhost", 3123, [package("foo", "1.0.0")]);
828 534
829 dir(appPath, [ 535 appDir([dependency("foo")]).scheduleCreate();
830 file('pubspec.yaml', '''
831 dependencies:
832 foo:
833 repo: {name: foo, url: http://localhost:3123}
834 ''')
835 ]).scheduleCreate();
836 536
837 schedulePub(args: ['install'], 537 schedulePub(args: ['install'],
838 output: const RegExp(@"Dependencies installed!$")); 538 output: const RegExp(@"Dependencies installed!$"));
839 539
840 dir(packagesPath, [ 540 packagesDir({"foo": "1.0.0"}).scheduleValidate();
841 dir('foo', [
842 file('foo.dart', 'main() => print("foo 1.0.0");')
843 ])
844 ]).scheduleValidate();
845 541
846 servePackages("localhost", 3123, [ 542 servePackages("localhost", 3123, [
847 '{name: foo, version: 1.0.0}', 543 package("foo", "1.0.0"),
848 '{name: foo, version: 1.0.1}' 544 package("foo", "1.0.1")
849 ]); 545 ]);
850 546
851 dir(appPath, [ 547 appDir([dependency("foo", ">=1.0.0")]).scheduleCreate();
852 file('pubspec.yaml', '''
853 dependencies:
854 foo:
855 repo: {name: foo, url: http://localhost:3123}
856 version: ">=1.0.0"
857 ''')
858 ]).scheduleCreate();
859 548
860 schedulePub(args: ['install'], 549 schedulePub(args: ['install'],
861 output: const RegExp(@"Dependencies installed!$")); 550 output: const RegExp(@"Dependencies installed!$"));
862 551
863 dir(packagesPath, [ 552 packagesDir({"foo": "1.0.0"}).scheduleValidate();
864 dir('foo', [
865 file('foo.dart', 'main() => print("foo 1.0.0");')
866 ])
867 ]).scheduleValidate();
868 553
869 run(); 554 run();
870 }); 555 });
871 556
872 test("unlocks dependencies if necessary to ensure that a new dependency " 557 test("unlocks dependencies if necessary to ensure that a new dependency "
873 "is satisfied", () { 558 "is satisfied", () {
874 servePackages("localhost", 3123, [ 559 servePackages("localhost", 3123, [
875 ''' 560 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
876 name: foo 561 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]),
877 version: 1.0.0 562 package("baz", "1.0.0", [dependency("qux", "<2.0.0")]),
878 dependencies: 563 package("qux", "1.0.0")
879 bar: 564 ]);
880 version: "<2.0.0"
881 repo: {name: bar, url: http://localhost:3123}
882 ''',
883 '''
884 name: bar
885 version: 1.0.0
886 dependencies:
887 baz:
888 version: "<2.0.0"
889 repo: {name: baz, url: http://localhost:3123}
890 ''',
891 '''
892 name: baz
893 version: 1.0.0
894 dependencies:
895 qux:
896 version: "<2.0.0"
897 repo: {name: qux, url: http://localhost:3123}
898 ''',
899 '''
900 name: qux
901 version: 1.0.0
902 ''']);
903 565
904 dir(appPath, [ 566 appDir([dependency("foo")]).scheduleCreate();
905 file('pubspec.yaml', '''
906 dependencies:
907 foo:
908 repo: {name: foo, url: http://localhost:3123}
909 ''')
910 ]).scheduleCreate();
911 567
912 schedulePub(args: ['install'], 568 schedulePub(args: ['install'],
913 output: const RegExp(@"Dependencies installed!$")); 569 output: const RegExp(@"Dependencies installed!$"));
914 570
915 dir(packagesPath, [ 571 packagesDir({
916 dir('foo', [ 572 "foo": "1.0.0",
917 file('foo.dart', 'main() => print("foo 1.0.0");') 573 "bar": "1.0.0",
918 ]), 574 "baz": "1.0.0",
919 dir('bar', [ 575 "qux": "1.0.0"
920 file('bar.dart', 'main() => print("bar 1.0.0");') 576 }).scheduleValidate();
921 ]),
922 dir('baz', [
923 file('baz.dart', 'main() => print("baz 1.0.0");')
924 ]),
925 dir('qux', [
926 file('qux.dart', 'main() => print("qux 1.0.0");')
927 ])
928 ]).scheduleValidate();
929 577
930 servePackages("localhost", 3123, [ 578 servePackages("localhost", 3123, [
931 ''' 579 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
932 name: foo 580 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]),
933 version: 1.0.0
934 dependencies:
935 bar:
936 version: "<2.0.0"
937 repo: {name: bar, url: http://localhost:3123}
938 ''',
939 '''
940 name: foo
941 version: 2.0.0
942 dependencies:
943 bar:
944 version: "<3.0.0"
945 repo: {name: bar, url: http://localhost:3123}
946 ''',
947 '''
948 name: bar
949 version: 1.0.0
950 dependencies:
951 baz:
952 version: "<2.0.0"
953 repo: {name: baz, url: http://localhost:3123}
954 ''',
955 '''
956 name: bar
957 version: 2.0.0
958 dependencies:
959 baz:
960 version: "<3.0.0"
961 repo: {name: baz, url: http://localhost:3123}
962 ''',
963 '''
964 name: baz
965 version: 1.0.0
966 dependencies:
967 qux:
968 version: "<2.0.0"
969 repo: {name: qux, url: http://localhost:3123}
970 ''',
971 '''
972 name: baz
973 version: 2.0.0
974 dependencies:
975 qux:
976 version: "<3.0.0"
977 repo: {name: qux, url: http://localhost:3123}
978 ''',
979 '''
980 name: qux
981 version: 1.0.0
982 ''',
983 '''
984 name: qux
985 version: 2.0.0
986 ''',
987 '''
988 name: newdep
989 version: 2.0.0
990 dependencies:
991 baz:
992 version: ">=1.5.0"
993 repo: {name: baz, url: http://localhost:3123}
994 ''']);
995 581
996 dir(appPath, [ 582 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]),
997 file('pubspec.yaml', ''' 583 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]),
998 dependencies: 584
999 foo: 585 package("baz", "1.0.0", [dependency("qux", "<2.0.0")]),
1000 repo: {name: foo, url: http://localhost:3123} 586 package("baz", "2.0.0", [dependency("qux", "<3.0.0")]),
1001 newdep: 587
1002 repo: {name: newdep, url: http://localhost:3123} 588 package("qux", "1.0.0"),
1003 ''') 589 package("qux", "2.0.0"),
1004 ]).scheduleCreate(); 590
591 package("newdep", "2.0.0", [dependency("baz", ">=1.5.0")])
592 ]);
593
594 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate();
1005 595
1006 schedulePub(args: ['install'], 596 schedulePub(args: ['install'],
1007 output: const RegExp(@"Dependencies installed!$")); 597 output: const RegExp(@"Dependencies installed!$"));
1008 598
1009 dir(packagesPath, [ 599 packagesDir({
1010 dir('foo', [ 600 "foo": "2.0.0",
1011 file('foo.dart', 'main() => print("foo 2.0.0");') 601 "bar": "2.0.0",
1012 ]), 602 "baz": "2.0.0",
1013 dir('bar', [ 603 "qux": "1.0.0",
1014 file('bar.dart', 'main() => print("bar 2.0.0");') 604 "newdep": "2.0.0"
1015 ]), 605 }).scheduleValidate();
1016 dir('baz', [
1017 file('baz.dart', 'main() => print("baz 2.0.0");')
1018 ]),
1019 dir('qux', [
1020 file('qux.dart', 'main() => print("qux 1.0.0");')
1021 ]),
1022 dir('newdep', [
1023 file('newdep.dart', 'main() => print("newdep 2.0.0");')
1024 ])
1025 ]).scheduleValidate();
1026 606
1027 run(); 607 run();
1028 }); 608 });
1029 609
1030 test("doesn't unlock dependencies if a new dependency is already " 610 test("doesn't unlock dependencies if a new dependency is already "
1031 "satisfied", () { 611 "satisfied", () {
1032 servePackages("localhost", 3123, [ 612 servePackages("localhost", 3123, [
1033 ''' 613 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
1034 name: foo 614 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]),
1035 version: 1.0.0 615 package("baz", "1.0.0")
1036 dependencies: 616 ]);
1037 bar:
1038 version: "<2.0.0"
1039 repo: {name: bar, url: http://localhost:3123}
1040 ''',
1041 '''
1042 name: bar
1043 version: 1.0.0
1044 dependencies:
1045 baz:
1046 version: "<2.0.0"
1047 repo: {name: baz, url: http://localhost:3123}
1048 ''',
1049 '''
1050 name: baz
1051 version: 1.0.0
1052 ''']);
1053 617
1054 dir(appPath, [ 618 appDir([dependency("foo")]).scheduleCreate();
1055 file('pubspec.yaml', '''
1056 dependencies:
1057 foo:
1058 repo: {name: foo, url: http://localhost:3123}
1059 ''')
1060 ]).scheduleCreate();
1061 619
1062 schedulePub(args: ['install'], 620 schedulePub(args: ['install'],
1063 output: const RegExp(@"Dependencies installed!$")); 621 output: const RegExp(@"Dependencies installed!$"));
1064 622
1065 dir(packagesPath, [ 623 packagesDir({
1066 dir('foo', [ 624 "foo": "1.0.0",
1067 file('foo.dart', 'main() => print("foo 1.0.0");') 625 "bar": "1.0.0",
1068 ]), 626 "baz": "1.0.0"
1069 dir('bar', [ 627 }).scheduleValidate();
1070 file('bar.dart', 'main() => print("bar 1.0.0");')
1071 ]),
1072 dir('baz', [
1073 file('baz.dart', 'main() => print("baz 1.0.0");')
1074 ])
1075 ]).scheduleValidate();
1076 628
1077 servePackages("localhost", 3123, [ 629 servePackages("localhost", 3123, [
1078 ''' 630 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
1079 name: foo 631 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]),
1080 version: 1.0.0
1081 dependencies:
1082 bar:
1083 version: "<2.0.0"
1084 repo: {name: bar, url: http://localhost:3123}
1085 ''',
1086 '''
1087 name: foo
1088 version: 2.0.0
1089 dependencies:
1090 bar:
1091 version: "<3.0.0"
1092 repo: {name: bar, url: http://localhost:3123}
1093 ''',
1094 '''
1095 name: bar
1096 version: 1.0.0
1097 dependencies:
1098 baz:
1099 version: "<2.0.0"
1100 repo: {name: baz, url: http://localhost:3123}
1101 ''',
1102 '''
1103 name: bar
1104 version: 2.0.0
1105 dependencies:
1106 baz:
1107 version: "<3.0.0"
1108 repo: {name: baz, url: http://localhost:3123}
1109 ''',
1110 '''
1111 name: baz
1112 version: 1.0.0
1113 ''',
1114 '''
1115 name: baz
1116 version: 2.0.0
1117 ''',
1118 '''
1119 name: newdep
1120 version: 2.0.0
1121 dependencies:
1122 baz:
1123 version: ">=1.0.0"
1124 repo: {name: baz, url: http://localhost:3123}
1125 ''']);
1126 632
1127 dir(appPath, [ 633 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]),
1128 file('pubspec.yaml', ''' 634 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]),
1129 dependencies: 635
1130 foo: 636 package("baz", "1.0.0"),
1131 repo: {name: foo, url: http://localhost:3123} 637 package("baz", "2.0.0"),
1132 newdep: 638
1133 repo: {name: newdep, url: http://localhost:3123} 639 package("newdep", "2.0.0", [dependency("baz", ">=1.0.0")])
1134 ''') 640 ]);
1135 ]).scheduleCreate(); 641
642 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate();
1136 643
1137 schedulePub(args: ['install'], 644 schedulePub(args: ['install'],
1138 output: const RegExp(@"Dependencies installed!$")); 645 output: const RegExp(@"Dependencies installed!$"));
1139 646
1140 dir(packagesPath, [ 647 packagesDir({
1141 dir('foo', [ 648 "foo": "1.0.0",
1142 file('foo.dart', 'main() => print("foo 1.0.0");') 649 "bar": "1.0.0",
1143 ]), 650 "baz": "1.0.0",
1144 dir('bar', [ 651 "newdep": "2.0.0"
1145 file('bar.dart', 'main() => print("bar 1.0.0");') 652 }).scheduleValidate();
1146 ]),
1147 dir('baz', [
1148 file('baz.dart', 'main() => print("baz 1.0.0");')
1149 ]),
1150 dir('newdep', [
1151 file('newdep.dart', 'main() => print("newdep 2.0.0");')
1152 ])
1153 ]).scheduleValidate();
1154 653
1155 run(); 654 run();
1156 }); 655 });
1157 } 656 }
1158 657
1159 updateCommand() { 658 updateCommand() {
1160 test("updates locked Git packages", () { 659 test("updates locked Git packages", () {
1161 ensureGit(); 660 ensureGit();
1162 661
1163 git('foo.git', [ 662 git('foo.git', [
1164 file('foo.dart', 'main() => "foo";') 663 file('foo.dart', 'main() => "foo";')
1165 ]).scheduleCreate(); 664 ]).scheduleCreate();
1166 665
1167 git('bar.git', [ 666 git('bar.git', [
1168 file('bar.dart', 'main() => "bar";') 667 file('bar.dart', 'main() => "bar";')
1169 ]).scheduleCreate(); 668 ]).scheduleCreate();
1170 669
1171 dir(appPath, [ 670 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate();
1172 file('pubspec.yaml', '''
1173 dependencies:
1174 foo:
1175 git: ../foo.git
1176 bar:
1177 git: ../bar.git
1178 ''')
1179 ]).scheduleCreate();
1180 671
1181 schedulePub(args: ['install'], 672 schedulePub(args: ['install'],
1182 output: const RegExp(@"Dependencies installed!$")); 673 output: const RegExp(@"Dependencies installed!$"));
1183 674
1184 dir(packagesPath, [ 675 dir(packagesPath, [
1185 dir('foo', [ 676 dir('foo', [
1186 file('foo.dart', 'main() => "foo";') 677 file('foo.dart', 'main() => "foo";')
1187 ]), 678 ]),
1188 dir('bar', [ 679 dir('bar', [
1189 file('bar.dart', 'main() => "bar";') 680 file('bar.dart', 'main() => "bar";')
(...skipping 28 matching lines...) Expand all
1218 ensureGit(); 709 ensureGit();
1219 710
1220 git('foo.git', [ 711 git('foo.git', [
1221 file('foo.dart', 'main() => "foo";') 712 file('foo.dart', 'main() => "foo";')
1222 ]).scheduleCreate(); 713 ]).scheduleCreate();
1223 714
1224 git('bar.git', [ 715 git('bar.git', [
1225 file('bar.dart', 'main() => "bar";') 716 file('bar.dart', 'main() => "bar";')
1226 ]).scheduleCreate(); 717 ]).scheduleCreate();
1227 718
1228 dir(appPath, [ 719 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate();
1229 file('pubspec.yaml', '''
1230 dependencies:
1231 foo:
1232 git: ../foo.git
1233 bar:
1234 git: ../bar.git
1235 ''')
1236 ]).scheduleCreate();
1237 720
1238 schedulePub(args: ['install'], 721 schedulePub(args: ['install'],
1239 output: const RegExp(@"Dependencies installed!$")); 722 output: const RegExp(@"Dependencies installed!$"));
1240 723
1241 dir(packagesPath, [ 724 dir(packagesPath, [
1242 dir('foo', [ 725 dir('foo', [
1243 file('foo.dart', 'main() => "foo";') 726 file('foo.dart', 'main() => "foo";')
1244 ]), 727 ]),
1245 dir('bar', [ 728 dir('bar', [
1246 file('bar.dart', 'main() => "bar";') 729 file('bar.dart', 'main() => "bar";')
(...skipping 22 matching lines...) Expand all
1269 752
1270 run(); 753 run();
1271 }); 754 });
1272 755
1273 test("doesn't update one locked Git package's dependencies if it's not " 756 test("doesn't update one locked Git package's dependencies if it's not "
1274 "necessary", () { 757 "necessary", () {
1275 ensureGit(); 758 ensureGit();
1276 759
1277 git('foo.git', [ 760 git('foo.git', [
1278 file('foo.dart', 'main() => "foo";'), 761 file('foo.dart', 'main() => "foo";'),
1279 file('pubspec.yaml', ''' 762 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}])
1280 dependencies:
1281 foo-dep:
1282 git: ../foo-dep.git
1283 ''')
1284 ]).scheduleCreate(); 763 ]).scheduleCreate();
1285 764
1286 git('foo-dep.git', [ 765 git('foo-dep.git', [
1287 file('foo-dep.dart', 'main() => "foo-dep";') 766 file('foo-dep.dart', 'main() => "foo-dep";'),
1288 ]).scheduleCreate(); 767 ]).scheduleCreate();
1289 768
1290 dir(appPath, [ 769 appDir([{"git": "../foo.git"}]).scheduleCreate();
1291 file('pubspec.yaml', '''
1292 dependencies:
1293 foo:
1294 git: ../foo.git
1295 ''')
1296 ]).scheduleCreate();
1297 770
1298 schedulePub(args: ['install'], 771 schedulePub(args: ['install'],
1299 output: const RegExp(@"Dependencies installed!$")); 772 output: const RegExp(@"Dependencies installed!$"));
1300 773
1301 dir(packagesPath, [ 774 dir(packagesPath, [
1302 dir('foo', [ 775 dir('foo', [
1303 file('foo.dart', 'main() => "foo";'), 776 file('foo.dart', 'main() => "foo";'),
1304 file('pubspec.yaml', ''' 777 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}])
1305 dependencies:
1306 foo-dep:
1307 git: ../foo-dep.git
1308 ''')
1309 ]), 778 ]),
1310 dir('foo-dep', [ 779 dir('foo-dep', [
1311 file('foo-dep.dart', 'main() => "foo-dep";') 780 file('foo-dep.dart', 'main() => "foo-dep";')
1312 ]) 781 ])
1313 ]).scheduleValidate(); 782 ]).scheduleValidate();
1314 783
1315 git('foo.git', [ 784 git('foo.git', [
1316 file('foo.dart', 'main() => "foo 2";'), 785 file('foo.dart', 'main() => "foo 2";'),
1317 file('pubspec.yaml', ''' 786 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}])
1318 dependencies:
1319 foo-dep:
1320 git: ../foo-dep.git
1321 ''')
1322 ]).scheduleCreate(); 787 ]).scheduleCreate();
1323 788
1324 git('foo-dep.git', [ 789 git('foo-dep.git', [
1325 file('foo-dep.dart', 'main() => "foo-dep 2";') 790 file('foo-dep.dart', 'main() => "foo-dep 2";')
1326 ]).scheduleCommit(); 791 ]).scheduleCommit();
1327 792
1328 schedulePub(args: ['update', 'foo'], 793 schedulePub(args: ['update', 'foo'],
1329 output: const RegExp(@"Dependencies updated!$")); 794 output: const RegExp(@"Dependencies updated!$"));
1330 795
1331 dir(packagesPath, [ 796 dir(packagesPath, [
1332 dir('foo', [ 797 dir('foo', [
1333 file('foo.dart', 'main() => "foo 2";'), 798 file('foo.dart', 'main() => "foo 2";'),
1334 file('pubspec.yaml', ''' 799 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}])
1335 dependencies:
1336 foo-dep:
1337 git: ../foo-dep.git
1338 ''')
1339 ]), 800 ]),
1340 dir('foo-dep', [ 801 dir('foo-dep', [
1341 file('foo-dep.dart', 'main() => "foo-dep";') 802 file('foo-dep.dart', 'main() => "foo-dep";')
1342 ]), 803 ]),
1343 ]).scheduleValidate(); 804 ]).scheduleValidate();
1344 805
1345 run(); 806 run();
1346 }); 807 });
1347 808
1348 test("updates one locked pub server package's dependencies if it's " 809 test("updates one locked pub server package's dependencies if it's "
1349 "necessary", () { 810 "necessary", () {
1350 servePackages("localhost", 3123, [ 811 servePackages("localhost", 3123, [
1351 ''' 812 package("foo", "1.0.0", [dependency("foo-dep")]),
1352 name: foo 813 package("foo-dep", "1.0.0")
1353 version: 1.0.0
1354 dependencies:
1355 foo-dep:
1356 repo:
1357 name: foo-dep
1358 url: http://localhost:3123
1359 ''',
1360 '{name: foo-dep, version: 1.0.0}'
1361 ]); 814 ]);
1362 815
1363 dir(appPath, [ 816 appDir([dependency("foo")]).scheduleCreate();
1364 file('pubspec.yaml', '''
1365 dependencies:
1366 foo:
1367 repo:
1368 name: foo
1369 url: http://localhost:3123
1370 ''')
1371 ]).scheduleCreate();
1372 817
1373 schedulePub(args: ['install'], 818 schedulePub(args: ['install'],
1374 output: const RegExp(@"Dependencies installed!$")); 819 output: const RegExp(@"Dependencies installed!$"));
1375 820
1376 dir(packagesPath, [ 821 packagesDir({
1377 dir('foo', [ 822 "foo": "1.0.0",
1378 file('foo.dart', 'main() => print("foo 1.0.0");'), 823 "foo-dep": "1.0.0"
1379 file('pubspec.yaml', ''' 824 }).scheduleValidate();
1380 name: foo
1381 version: 1.0.0
1382 dependencies:
1383 foo-dep:
1384 repo:
1385 name: foo-dep
1386 url: http://localhost:3123
1387 ''')
1388 ]),
1389 dir('foo-dep', [
1390 file('foo-dep.dart', 'main() => print("foo-dep 1.0.0");')
1391 ])
1392 ]).scheduleValidate();
1393 825
1394 servePackages("localhost", 3123, [ 826 servePackages("localhost", 3123, [
1395 ''' 827 package("foo", "2.0.0", [dependency("foo-dep", ">1.0.0")]),
1396 name: foo 828 package("foo-dep", "2.0.0")
1397 version: 2.0.0
1398 dependencies:
1399 foo-dep:
1400 repo: {name: foo-dep, url: http://localhost:3123}
1401 version: ">1.0.0"
1402 ''',
1403 '{name: foo-dep, version: 2.0.0}'
1404 ]); 829 ]);
1405 830
1406 schedulePub(args: ['update', 'foo'], 831 schedulePub(args: ['update', 'foo'],
1407 output: const RegExp(@"Dependencies updated!$")); 832 output: const RegExp(@"Dependencies updated!$"));
1408 833
1409 dir(packagesPath, [ 834 packagesDir({
1410 dir('foo', [ 835 "foo": "2.0.0",
1411 file('foo.dart', 'main() => print("foo 2.0.0");'), 836 "foo-dep": "2.0.0"
1412 file('pubspec.yaml', ''' 837 }).scheduleValidate();
1413 name: foo
1414 version: 2.0.0
1415 dependencies:
1416 foo-dep:
1417 repo: {name: foo-dep, url: http://localhost:3123}
1418 version: ">1.0.0"
1419 ''')
1420 ]),
1421 dir('foo-dep', [
1422 file('foo-dep.dart', 'main() => print("foo-dep 2.0.0");')
1423 ])
1424 ]).scheduleValidate();
1425 838
1426 run(); 839 run();
1427 }); 840 });
1428 841
1429 test("updates a locked package's dependers in order to get it to max " 842 test("updates a locked package's dependers in order to get it to max "
1430 "version", () { 843 "version", () {
1431 servePackages("localhost", 3123, [ 844 servePackages("localhost", 3123, [
1432 ''' 845 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
1433 name: foo 846 package("bar", "1.0.0")
1434 version: 1.0.0
1435 dependencies:
1436 bar:
1437 version: "<2.0.0"
1438 repo: {name: bar, url: http://localhost:3123}
1439 ''',
1440 '{name: bar, version: 1.0.0}'
1441 ]); 847 ]);
1442 848
1443 dir(appPath, [ 849 appDir([dependency("foo"), dependency("bar")]).scheduleCreate();
1444 file('pubspec.yaml', '''
1445 dependencies:
1446 foo:
1447 repo: {name: foo, url: http://localhost:3123}
1448 bar:
1449 repo: {name: bar, url: http://localhost:3123}
1450 ''')
1451 ]).scheduleCreate();
1452 850
1453 schedulePub(args: ['install'], 851 schedulePub(args: ['install'],
1454 output: const RegExp(@"Dependencies installed!$")); 852 output: const RegExp(@"Dependencies installed!$"));
1455 853
1456 dir(packagesPath, [ 854 packagesDir({
1457 dir('foo', [ 855 "foo": "1.0.0",
1458 file('foo.dart', 'main() => print("foo 1.0.0");'), 856 "bar": "1.0.0"
1459 ]), 857 }).scheduleValidate();
1460 dir('bar', [
1461 file('bar.dart', 'main() => print("bar 1.0.0");')
1462 ])
1463 ]).scheduleValidate();
1464 858
1465 servePackages("localhost", 3123, [ 859 servePackages("localhost", 3123, [
1466 ''' 860 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]),
1467 name: foo 861 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]),
1468 version: 1.0.0 862
1469 dependencies: 863 package("bar", "1.0.0"),
1470 bar: 864 package("bar", "2.0.0")
1471 version: "<2.0.0"
1472 repo: {name: bar, url: http://localhost:3123}
1473 ''',
1474 '''
1475 name: foo
1476 version: 2.0.0
1477 dependencies:
1478 bar:
1479 version: "<3.0.0"
1480 repo: {name: bar, url: http://localhost:3123}
1481 ''',
1482 '{name: bar, version: 1.0.0}',
1483 '{name: bar, version: 2.0.0}'
1484 ]); 865 ]);
1485 866
1486 schedulePub(args: ['update', 'bar'], 867 schedulePub(args: ['update', 'bar'],
1487 output: const RegExp(@"Dependencies updated!$")); 868 output: const RegExp(@"Dependencies updated!$"));
1488 869
1489 dir(packagesPath, [ 870 packagesDir({
1490 dir('foo', [ 871 "foo": "2.0.0",
1491 file('foo.dart', 'main() => print("foo 2.0.0");'), 872 "bar": "2.0.0"
1492 ]), 873 }).scheduleValidate();
1493 dir('bar', [
1494 file('bar.dart', 'main() => print("bar 2.0.0");')
1495 ])
1496 ]).scheduleValidate();
1497 874
1498 run(); 875 run();
1499 }); 876 });
1500 }); 877 });
1501 } 878 }
1502 879
1503 versionCommand() { 880 versionCommand() {
1504 test('displays the current version', () => 881 test('displays the current version', () =>
1505 runPub(args: ['version'], output: VERSION_STRING)); 882 runPub(args: ['version'], output: VERSION_STRING));
1506 } 883 }
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | utils/tests/pub/test_pub.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698