| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 test('displays an error message', () { | 50 test('displays an error message', () { |
| 51 runPub(args: ['quylthulg'], | 51 runPub(args: ['quylthulg'], |
| 52 error: ''' | 52 error: ''' |
| 53 Unknown command "quylthulg". | 53 Unknown command "quylthulg". |
| 54 Run "pub help" to see available commands. | 54 Run "pub help" to see available commands. |
| 55 ''', | 55 ''', |
| 56 exitCode: 64); | 56 exitCode: 64); |
| 57 }); | 57 }); |
| 58 }); | 58 }); |
| 59 | 59 |
| 60 group('pub list', listCommand); | |
| 61 group('pub install', installCommand); | |
| 62 group('pub update', updateCommand); | |
| 63 group('pub version', versionCommand); | |
| 64 } | |
| 65 | |
| 66 listCommand() { | |
| 67 // TODO(rnystrom): We don't currently have any sources that are cached, so | |
| 68 // we can't test this right now. | |
| 69 /* | |
| 70 group('cache', () { | |
| 71 test('treats an empty directory as a package', () { | |
| 72 dir(cachePath, [ | |
| 73 dir('sdk', [ | |
| 74 dir('apple'), | |
| 75 dir('banana'), | |
| 76 dir('cherry') | |
| 77 ]) | |
| 78 ]).scheduleCreate(); | |
| 79 | |
| 80 runPub(args: ['list', 'cache'], | |
| 81 output: ''' | |
| 82 From system cache: | |
| 83 apple 0.0.0 (apple from sdk) | |
| 84 banana 0.0.0 (banana from sdk) | |
| 85 cherry 0.0.0 (cherry from sdk) | |
| 86 '''); | |
| 87 }); | |
| 88 }); | |
| 89 */ | |
| 90 } | |
| 91 | |
| 92 installCommand() { | |
| 93 test('checks out a package from the SDK', () { | |
| 94 dir(sdkPath, [ | |
| 95 file('revision', '1234'), | |
| 96 dir('pkg', [packageDir("foo", "0.0.1234")]) | |
| 97 ]).scheduleCreate(); | |
| 98 | |
| 99 dir(appPath, [ | |
| 100 pubspec({"dependencies": {"foo": null}}) | |
| 101 ]).scheduleCreate(); | |
| 102 | |
| 103 schedulePub(args: ['install'], | |
| 104 output: ''' | |
| 105 Dependencies installed! | |
| 106 '''); | |
| 107 | |
| 108 packagesDir({"foo": "0.0.1234"}).scheduleValidate(); | |
| 109 | |
| 110 run(); | |
| 111 }); | |
| 112 | |
| 113 test('checks out a package from Git', () { | |
| 114 ensureGit(); | |
| 115 | |
| 116 git('foo.git', [ | |
| 117 file('foo.dart', 'main() => "foo";') | |
| 118 ]).scheduleCreate(); | |
| 119 | |
| 120 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 121 | |
| 122 schedulePub(args: ['install'], | |
| 123 output: const RegExp(@"Dependencies installed!$")); | |
| 124 | |
| 125 dir(cachePath, [ | |
| 126 dir('git', [ | |
| 127 dir('cache', [gitPackageCacheDir('foo')]), | |
| 128 gitPackageCacheDir('foo') | |
| 129 ]) | |
| 130 ]).scheduleValidate(); | |
| 131 | |
| 132 dir(packagesPath, [ | |
| 133 dir('foo', [ | |
| 134 file('foo.dart', 'main() => "foo";') | |
| 135 ]) | |
| 136 ]).scheduleValidate(); | |
| 137 | |
| 138 run(); | |
| 139 }); | |
| 140 | |
| 141 test('checks out packages transitively from Git', () { | |
| 142 ensureGit(); | |
| 143 | |
| 144 git('foo.git', [ | |
| 145 file('foo.dart', 'main() => "foo";'), | |
| 146 appPubspec([{"git": "../bar.git"}]) | |
| 147 ]).scheduleCreate(); | |
| 148 | |
| 149 git('bar.git', [ | |
| 150 file('bar.dart', 'main() => "bar";') | |
| 151 ]).scheduleCreate(); | |
| 152 | |
| 153 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 154 | |
| 155 schedulePub(args: ['install'], | |
| 156 output: const RegExp("Dependencies installed!\$")); | |
| 157 | |
| 158 dir(cachePath, [ | |
| 159 dir('git', [ | |
| 160 dir('cache', [ | |
| 161 gitPackageCacheDir('foo'), | |
| 162 gitPackageCacheDir('bar') | |
| 163 ]), | |
| 164 gitPackageCacheDir('foo'), | |
| 165 gitPackageCacheDir('bar') | |
| 166 ]) | |
| 167 ]).scheduleValidate(); | |
| 168 | |
| 169 dir(packagesPath, [ | |
| 170 dir('foo', [ | |
| 171 file('foo.dart', 'main() => "foo";') | |
| 172 ]), | |
| 173 dir('bar', [ | |
| 174 file('bar.dart', 'main() => "bar";') | |
| 175 ]) | |
| 176 ]).scheduleValidate(); | |
| 177 | |
| 178 run(); | |
| 179 }); | |
| 180 | |
| 181 test('checks out and updates a package from Git', () { | |
| 182 ensureGit(); | |
| 183 | |
| 184 git('foo.git', [ | |
| 185 file('foo.dart', 'main() => "foo";') | |
| 186 ]).scheduleCreate(); | |
| 187 | |
| 188 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 189 | |
| 190 schedulePub(args: ['install'], | |
| 191 output: const RegExp(@"Dependencies installed!$")); | |
| 192 | |
| 193 dir(cachePath, [ | |
| 194 dir('git', [ | |
| 195 dir('cache', [gitPackageCacheDir('foo')]), | |
| 196 gitPackageCacheDir('foo') | |
| 197 ]) | |
| 198 ]).scheduleValidate(); | |
| 199 | |
| 200 dir(packagesPath, [ | |
| 201 dir('foo', [ | |
| 202 file('foo.dart', 'main() => "foo";') | |
| 203 ]) | |
| 204 ]).scheduleValidate(); | |
| 205 | |
| 206 // TODO(nweiz): remove this once we support pub update | |
| 207 dir(packagesPath).scheduleDelete(); | |
| 208 file('$appPath/pubspec.lock', '').scheduleDelete(); | |
| 209 | |
| 210 git('foo.git', [ | |
| 211 file('foo.dart', 'main() => "foo 2";') | |
| 212 ]).scheduleCommit(); | |
| 213 | |
| 214 schedulePub(args: ['install'], | |
| 215 output: const RegExp(@"Dependencies installed!$")); | |
| 216 | |
| 217 // When we download a new version of the git package, we should re-use the | |
| 218 // git/cache directory but create a new git/ directory. | |
| 219 dir(cachePath, [ | |
| 220 dir('git', [ | |
| 221 dir('cache', [gitPackageCacheDir('foo', 2)]), | |
| 222 gitPackageCacheDir('foo'), | |
| 223 gitPackageCacheDir('foo', 2) | |
| 224 ]) | |
| 225 ]).scheduleValidate(); | |
| 226 | |
| 227 dir(packagesPath, [ | |
| 228 dir('foo', [ | |
| 229 file('foo.dart', 'main() => "foo 2";') | |
| 230 ]) | |
| 231 ]).scheduleValidate(); | |
| 232 | |
| 233 run(); | |
| 234 }); | |
| 235 | |
| 236 test('checks out a package from Git twice', () { | |
| 237 ensureGit(); | |
| 238 | |
| 239 git('foo.git', [ | |
| 240 file('foo.dart', 'main() => "foo";') | |
| 241 ]).scheduleCreate(); | |
| 242 | |
| 243 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 244 | |
| 245 schedulePub(args: ['install'], | |
| 246 output: const RegExp(@"Dependencies installed!$")); | |
| 247 | |
| 248 dir(cachePath, [ | |
| 249 dir('git', [ | |
| 250 dir('cache', [gitPackageCacheDir('foo')]), | |
| 251 gitPackageCacheDir('foo') | |
| 252 ]) | |
| 253 ]).scheduleValidate(); | |
| 254 | |
| 255 dir(packagesPath, [ | |
| 256 dir('foo', [ | |
| 257 file('foo.dart', 'main() => "foo";') | |
| 258 ]) | |
| 259 ]).scheduleValidate(); | |
| 260 | |
| 261 // TODO(nweiz): remove this once we support pub update | |
| 262 dir(packagesPath).scheduleDelete(); | |
| 263 | |
| 264 // Verify that nothing breaks if we install a Git revision that's already | |
| 265 // in the cache. | |
| 266 schedulePub(args: ['install'], | |
| 267 output: const RegExp(@"Dependencies installed!$")); | |
| 268 | |
| 269 run(); | |
| 270 }); | |
| 271 | |
| 272 test('checks out a package at a specific revision from Git', () { | |
| 273 ensureGit(); | |
| 274 | |
| 275 var repo = git('foo.git', [ | |
| 276 file('foo.dart', 'main() => "foo 1";') | |
| 277 ]); | |
| 278 repo.scheduleCreate(); | |
| 279 var commit = repo.revParse('HEAD'); | |
| 280 | |
| 281 git('foo.git', [ | |
| 282 file('foo.dart', 'main() => "foo 2";') | |
| 283 ]).scheduleCommit(); | |
| 284 | |
| 285 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate(); | |
| 286 | |
| 287 schedulePub(args: ['install'], | |
| 288 output: const RegExp(@"Dependencies installed!$")); | |
| 289 | |
| 290 dir(packagesPath, [ | |
| 291 dir('foo', [ | |
| 292 file('foo.dart', 'main() => "foo 1";') | |
| 293 ]) | |
| 294 ]).scheduleValidate(); | |
| 295 | |
| 296 run(); | |
| 297 }); | |
| 298 | |
| 299 test('checks out a package from a pub server', () { | |
| 300 servePackages([package("foo", "1.2.3")]); | |
| 301 | |
| 302 appDir([dependency("foo", "1.2.3")]).scheduleCreate(); | |
| 303 | |
| 304 schedulePub(args: ['install'], | |
| 305 output: const RegExp("Dependencies installed!\$")); | |
| 306 | |
| 307 cacheDir({"foo": "1.2.3"}).scheduleValidate(); | |
| 308 packagesDir({"foo": "1.2.3"}).scheduleValidate(); | |
| 309 | |
| 310 run(); | |
| 311 }); | |
| 312 | |
| 313 test('checks out packages transitively from a pub server', () { | |
| 314 servePackages([ | |
| 315 package("foo", "1.2.3", [dependency("bar", "2.0.4")]), | |
| 316 package("bar", "2.0.3"), | |
| 317 package("bar", "2.0.4"), | |
| 318 package("bar", "2.0.5") | |
| 319 ]); | |
| 320 | |
| 321 appDir([dependency("foo", "1.2.3")]).scheduleCreate(); | |
| 322 | |
| 323 schedulePub(args: ['install'], | |
| 324 output: const RegExp("Dependencies installed!\$")); | |
| 325 | |
| 326 cacheDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate(); | |
| 327 packagesDir({"foo": "1.2.3", "bar": "2.0.4"}).scheduleValidate(); | |
| 328 | |
| 329 run(); | |
| 330 }); | |
| 331 | |
| 332 test('resolves version constraints from a pub server', () { | |
| 333 servePackages([ | |
| 334 package("foo", "1.2.3", [dependency("baz", ">=2.0.0")]), | |
| 335 package("bar", "2.3.4", [dependency("baz", "<3.0.0")]), | |
| 336 package("baz", "2.0.3"), | |
| 337 package("baz", "2.0.4"), | |
| 338 package("baz", "3.0.1") | |
| 339 ]); | |
| 340 | |
| 341 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 342 | |
| 343 schedulePub(args: ['install'], | |
| 344 output: const RegExp("Dependencies installed!\$")); | |
| 345 | |
| 346 cacheDir({ | |
| 347 "foo": "1.2.3", | |
| 348 "bar": "2.3.4", | |
| 349 "baz": "2.0.4" | |
| 350 }).scheduleValidate(); | |
| 351 | |
| 352 packagesDir({ | |
| 353 "foo": "1.2.3", | |
| 354 "bar": "2.3.4", | |
| 355 "baz": "2.0.4" | |
| 356 }).scheduleValidate(); | |
| 357 | |
| 358 run(); | |
| 359 }); | |
| 360 | |
| 361 test('keeps a Git package locked to the version in the lockfile', () { | |
| 362 ensureGit(); | |
| 363 | |
| 364 git('foo.git', [ | |
| 365 file('foo.dart', 'main() => "foo";') | |
| 366 ]).scheduleCreate(); | |
| 367 | |
| 368 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 369 | |
| 370 // This install should lock the foo.git dependency to the current revision. | |
| 371 schedulePub(args: ['install'], | |
| 372 output: const RegExp(@"Dependencies installed!$")); | |
| 373 | |
| 374 dir(packagesPath, [ | |
| 375 dir('foo', [ | |
| 376 file('foo.dart', 'main() => "foo";') | |
| 377 ]) | |
| 378 ]).scheduleValidate(); | |
| 379 | |
| 380 // Delete the packages path to simulate a new checkout of the application. | |
| 381 dir(packagesPath).scheduleDelete(); | |
| 382 | |
| 383 git('foo.git', [ | |
| 384 file('foo.dart', 'main() => "foo 2";') | |
| 385 ]).scheduleCommit(); | |
| 386 | |
| 387 // This install shouldn't update the foo.git dependency due to the lockfile. | |
| 388 schedulePub(args: ['install'], | |
| 389 output: const RegExp(@"Dependencies installed!$")); | |
| 390 | |
| 391 dir(packagesPath, [ | |
| 392 dir('foo', [ | |
| 393 file('foo.dart', 'main() => "foo";') | |
| 394 ]) | |
| 395 ]).scheduleValidate(); | |
| 396 | |
| 397 run(); | |
| 398 }); | |
| 399 | |
| 400 test('updates a locked Git package with a new incompatible constraint', () { | |
| 401 ensureGit(); | |
| 402 | |
| 403 git('foo.git', [ | |
| 404 file('foo.dart', 'main() => "foo";') | |
| 405 ]).scheduleCreate(); | |
| 406 | |
| 407 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 408 | |
| 409 schedulePub(args: ['install'], | |
| 410 output: const RegExp(@"Dependencies installed!$")); | |
| 411 | |
| 412 dir(packagesPath, [ | |
| 413 dir('foo', [ | |
| 414 file('foo.dart', 'main() => "foo";') | |
| 415 ]) | |
| 416 ]).scheduleValidate(); | |
| 417 | |
| 418 git('foo.git', [ | |
| 419 file('foo.dart', 'main() => "foo 1.0.0";'), | |
| 420 libPubspec("foo", "1.0.0") | |
| 421 ]).scheduleCommit(); | |
| 422 | |
| 423 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); | |
| 424 | |
| 425 schedulePub(args: ['install'], | |
| 426 output: const RegExp(@"Dependencies installed!$")); | |
| 427 | |
| 428 dir(packagesPath, [ | |
| 429 dir('foo', [ | |
| 430 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 431 ]) | |
| 432 ]).scheduleValidate(); | |
| 433 | |
| 434 run(); | |
| 435 }); | |
| 436 | |
| 437 test("doesn't update a locked Git package with a new compatible " | |
| 438 "constraint", () { | |
| 439 ensureGit(); | |
| 440 | |
| 441 git('foo.git', [ | |
| 442 file('foo.dart', 'main() => "foo 1.0.0";'), | |
| 443 libPubspec("foo", "1.0.0") | |
| 444 ]).scheduleCreate(); | |
| 445 | |
| 446 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 447 | |
| 448 schedulePub(args: ['install'], | |
| 449 output: const RegExp(@"Dependencies installed!$")); | |
| 450 | |
| 451 dir(packagesPath, [ | |
| 452 dir('foo', [ | |
| 453 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 454 ]) | |
| 455 ]).scheduleValidate(); | |
| 456 | |
| 457 git('foo.git', [ | |
| 458 file('foo.dart', 'main() => "foo 1.0.1";'), | |
| 459 libPubspec("foo", "1.0.1") | |
| 460 ]).scheduleCommit(); | |
| 461 | |
| 462 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); | |
| 463 | |
| 464 schedulePub(args: ['install'], | |
| 465 output: const RegExp(@"Dependencies installed!$")); | |
| 466 | |
| 467 dir(packagesPath, [ | |
| 468 dir('foo', [ | |
| 469 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 470 ]) | |
| 471 ]).scheduleValidate(); | |
| 472 | |
| 473 run(); | |
| 474 }); | |
| 475 | |
| 476 test('keeps a pub server package locked to the version in the lockfile', () { | |
| 477 servePackages([package("foo", "1.0.0")]); | |
| 478 | |
| 479 appDir([dependency("foo")]).scheduleCreate(); | |
| 480 | |
| 481 // This install should lock the foo dependency to version 1.0.0. | |
| 482 schedulePub(args: ['install'], | |
| 483 output: const RegExp(@"Dependencies installed!$")); | |
| 484 | |
| 485 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
| 486 | |
| 487 // Delete the packages path to simulate a new checkout of the application. | |
| 488 dir(packagesPath).scheduleDelete(); | |
| 489 | |
| 490 // Start serving a newer package as well. | |
| 491 servePackages([package("foo", "1.0.1")]); | |
| 492 | |
| 493 // This install shouldn't update the foo dependency due to the lockfile. | |
| 494 schedulePub(args: ['install'], | |
| 495 output: const RegExp(@"Dependencies installed!$")); | |
| 496 | |
| 497 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
| 498 | |
| 499 run(); | |
| 500 }); | |
| 501 | |
| 502 test('updates a locked pub server package with a new incompatible ' | |
| 503 'constraint', () { | |
| 504 servePackages([package("foo", "1.0.0")]); | |
| 505 | |
| 506 appDir([dependency("foo")]).scheduleCreate(); | |
| 507 | |
| 508 schedulePub(args: ['install'], | |
| 509 output: const RegExp(@"Dependencies installed!$")); | |
| 510 | |
| 511 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
| 512 | |
| 513 servePackages([package("foo", "1.0.1")]); | |
| 514 | |
| 515 appDir([dependency("foo", ">1.0.0")]).scheduleCreate(); | |
| 516 | |
| 517 schedulePub(args: ['install'], | |
| 518 output: const RegExp(@"Dependencies installed!$")); | |
| 519 | |
| 520 packagesDir({"foo": "1.0.1"}).scheduleValidate(); | |
| 521 | |
| 522 run(); | |
| 523 }); | |
| 524 | |
| 525 test("doesn't update a locked pub server package with a new compatible " | |
| 526 "constraint", () { | |
| 527 servePackages([package("foo", "1.0.0")]); | |
| 528 | |
| 529 appDir([dependency("foo")]).scheduleCreate(); | |
| 530 | |
| 531 schedulePub(args: ['install'], | |
| 532 output: const RegExp(@"Dependencies installed!$")); | |
| 533 | |
| 534 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
| 535 | |
| 536 servePackages([package("foo", "1.0.1")]); | |
| 537 | |
| 538 appDir([dependency("foo", ">=1.0.0")]).scheduleCreate(); | |
| 539 | |
| 540 schedulePub(args: ['install'], | |
| 541 output: const RegExp(@"Dependencies installed!$")); | |
| 542 | |
| 543 packagesDir({"foo": "1.0.0"}).scheduleValidate(); | |
| 544 | |
| 545 run(); | |
| 546 }); | |
| 547 | |
| 548 test("unlocks dependencies if necessary to ensure that a new dependency " | |
| 549 "is satisfied", () { | |
| 550 servePackages([ | |
| 551 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
| 552 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]), | |
| 553 package("baz", "1.0.0", [dependency("qux", "<2.0.0")]), | |
| 554 package("qux", "1.0.0") | |
| 555 ]); | |
| 556 | |
| 557 appDir([dependency("foo")]).scheduleCreate(); | |
| 558 | |
| 559 schedulePub(args: ['install'], | |
| 560 output: const RegExp(@"Dependencies installed!$")); | |
| 561 | |
| 562 packagesDir({ | |
| 563 "foo": "1.0.0", | |
| 564 "bar": "1.0.0", | |
| 565 "baz": "1.0.0", | |
| 566 "qux": "1.0.0" | |
| 567 }).scheduleValidate(); | |
| 568 | |
| 569 servePackages([ | |
| 570 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
| 571 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]), | |
| 572 package("baz", "2.0.0", [dependency("qux", "<3.0.0")]), | |
| 573 package("qux", "2.0.0"), | |
| 574 package("newdep", "2.0.0", [dependency("baz", ">=1.5.0")]) | |
| 575 ]); | |
| 576 | |
| 577 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate(); | |
| 578 | |
| 579 schedulePub(args: ['install'], | |
| 580 output: const RegExp(@"Dependencies installed!$")); | |
| 581 | |
| 582 packagesDir({ | |
| 583 "foo": "2.0.0", | |
| 584 "bar": "2.0.0", | |
| 585 "baz": "2.0.0", | |
| 586 "qux": "1.0.0", | |
| 587 "newdep": "2.0.0" | |
| 588 }).scheduleValidate(); | |
| 589 | |
| 590 run(); | |
| 591 }); | |
| 592 | |
| 593 test("doesn't unlock dependencies if a new dependency is already " | |
| 594 "satisfied", () { | |
| 595 servePackages([ | |
| 596 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
| 597 package("bar", "1.0.0", [dependency("baz", "<2.0.0")]), | |
| 598 package("baz", "1.0.0") | |
| 599 ]); | |
| 600 | |
| 601 appDir([dependency("foo")]).scheduleCreate(); | |
| 602 | |
| 603 schedulePub(args: ['install'], | |
| 604 output: const RegExp(@"Dependencies installed!$")); | |
| 605 | |
| 606 packagesDir({ | |
| 607 "foo": "1.0.0", | |
| 608 "bar": "1.0.0", | |
| 609 "baz": "1.0.0" | |
| 610 }).scheduleValidate(); | |
| 611 | |
| 612 servePackages([ | |
| 613 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
| 614 package("bar", "2.0.0", [dependency("baz", "<3.0.0")]), | |
| 615 package("baz", "2.0.0"), | |
| 616 package("newdep", "2.0.0", [dependency("baz", ">=1.0.0")]) | |
| 617 ]); | |
| 618 | |
| 619 appDir([dependency("foo"), dependency("newdep")]).scheduleCreate(); | |
| 620 | |
| 621 schedulePub(args: ['install'], | |
| 622 output: const RegExp(@"Dependencies installed!$")); | |
| 623 | |
| 624 packagesDir({ | |
| 625 "foo": "1.0.0", | |
| 626 "bar": "1.0.0", | |
| 627 "baz": "1.0.0", | |
| 628 "newdep": "2.0.0" | |
| 629 }).scheduleValidate(); | |
| 630 | |
| 631 run(); | |
| 632 }); | |
| 633 } | |
| 634 | |
| 635 updateCommand() { | |
| 636 test("updates locked Git packages", () { | |
| 637 ensureGit(); | |
| 638 | |
| 639 git('foo.git', [ | |
| 640 file('foo.dart', 'main() => "foo";') | |
| 641 ]).scheduleCreate(); | |
| 642 | |
| 643 git('bar.git', [ | |
| 644 file('bar.dart', 'main() => "bar";') | |
| 645 ]).scheduleCreate(); | |
| 646 | |
| 647 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate(); | |
| 648 | |
| 649 schedulePub(args: ['install'], | |
| 650 output: const RegExp(@"Dependencies installed!$")); | |
| 651 | |
| 652 dir(packagesPath, [ | |
| 653 dir('foo', [ | |
| 654 file('foo.dart', 'main() => "foo";') | |
| 655 ]), | |
| 656 dir('bar', [ | |
| 657 file('bar.dart', 'main() => "bar";') | |
| 658 ]) | |
| 659 ]).scheduleValidate(); | |
| 660 | |
| 661 git('foo.git', [ | |
| 662 file('foo.dart', 'main() => "foo 2";') | |
| 663 ]).scheduleCommit(); | |
| 664 | |
| 665 git('bar.git', [ | |
| 666 file('bar.dart', 'main() => "bar 2";') | |
| 667 ]).scheduleCommit(); | |
| 668 | |
| 669 schedulePub(args: ['update'], | |
| 670 output: const RegExp(@"Dependencies updated!$")); | |
| 671 | |
| 672 dir(packagesPath, [ | |
| 673 dir('foo', [ | |
| 674 file('foo.dart', 'main() => "foo 2";') | |
| 675 ]), | |
| 676 dir('bar', [ | |
| 677 file('bar.dart', 'main() => "bar 2";') | |
| 678 ]) | |
| 679 ]).scheduleValidate(); | |
| 680 | |
| 681 run(); | |
| 682 }); | |
| 683 | |
| 684 group("with an argument", () { | |
| 685 test("updates one locked Git package but no others", () { | |
| 686 ensureGit(); | |
| 687 | |
| 688 git('foo.git', [ | |
| 689 file('foo.dart', 'main() => "foo";') | |
| 690 ]).scheduleCreate(); | |
| 691 | |
| 692 git('bar.git', [ | |
| 693 file('bar.dart', 'main() => "bar";') | |
| 694 ]).scheduleCreate(); | |
| 695 | |
| 696 appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).scheduleCreate(); | |
| 697 | |
| 698 schedulePub(args: ['install'], | |
| 699 output: const RegExp(@"Dependencies installed!$")); | |
| 700 | |
| 701 dir(packagesPath, [ | |
| 702 dir('foo', [ | |
| 703 file('foo.dart', 'main() => "foo";') | |
| 704 ]), | |
| 705 dir('bar', [ | |
| 706 file('bar.dart', 'main() => "bar";') | |
| 707 ]) | |
| 708 ]).scheduleValidate(); | |
| 709 | |
| 710 git('foo.git', [ | |
| 711 file('foo.dart', 'main() => "foo 2";') | |
| 712 ]).scheduleCommit(); | |
| 713 | |
| 714 git('bar.git', [ | |
| 715 file('bar.dart', 'main() => "bar 2";') | |
| 716 ]).scheduleCommit(); | |
| 717 | |
| 718 schedulePub(args: ['update', 'foo'], | |
| 719 output: const RegExp(@"Dependencies updated!$")); | |
| 720 | |
| 721 dir(packagesPath, [ | |
| 722 dir('foo', [ | |
| 723 file('foo.dart', 'main() => "foo 2";') | |
| 724 ]), | |
| 725 dir('bar', [ | |
| 726 file('bar.dart', 'main() => "bar";') | |
| 727 ]) | |
| 728 ]).scheduleValidate(); | |
| 729 | |
| 730 run(); | |
| 731 }); | |
| 732 | |
| 733 test("doesn't update one locked Git package's dependencies if it's not " | |
| 734 "necessary", () { | |
| 735 ensureGit(); | |
| 736 | |
| 737 git('foo.git', [ | |
| 738 file('foo.dart', 'main() => "foo";'), | |
| 739 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
| 740 ]).scheduleCreate(); | |
| 741 | |
| 742 git('foo-dep.git', [ | |
| 743 file('foo-dep.dart', 'main() => "foo-dep";'), | |
| 744 ]).scheduleCreate(); | |
| 745 | |
| 746 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 747 | |
| 748 schedulePub(args: ['install'], | |
| 749 output: const RegExp(@"Dependencies installed!$")); | |
| 750 | |
| 751 dir(packagesPath, [ | |
| 752 dir('foo', [ | |
| 753 file('foo.dart', 'main() => "foo";'), | |
| 754 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
| 755 ]), | |
| 756 dir('foo-dep', [ | |
| 757 file('foo-dep.dart', 'main() => "foo-dep";') | |
| 758 ]) | |
| 759 ]).scheduleValidate(); | |
| 760 | |
| 761 git('foo.git', [ | |
| 762 file('foo.dart', 'main() => "foo 2";'), | |
| 763 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
| 764 ]).scheduleCreate(); | |
| 765 | |
| 766 git('foo-dep.git', [ | |
| 767 file('foo-dep.dart', 'main() => "foo-dep 2";') | |
| 768 ]).scheduleCommit(); | |
| 769 | |
| 770 schedulePub(args: ['update', 'foo'], | |
| 771 output: const RegExp(@"Dependencies updated!$")); | |
| 772 | |
| 773 dir(packagesPath, [ | |
| 774 dir('foo', [ | |
| 775 file('foo.dart', 'main() => "foo 2";'), | |
| 776 libPubspec("foo", "1.0.0", [{"git": "../foo-dep.git"}]) | |
| 777 ]), | |
| 778 dir('foo-dep', [ | |
| 779 file('foo-dep.dart', 'main() => "foo-dep";') | |
| 780 ]), | |
| 781 ]).scheduleValidate(); | |
| 782 | |
| 783 run(); | |
| 784 }); | |
| 785 | |
| 786 test("updates one locked pub server package's dependencies if it's " | |
| 787 "necessary", () { | |
| 788 servePackages([ | |
| 789 package("foo", "1.0.0", [dependency("foo-dep")]), | |
| 790 package("foo-dep", "1.0.0") | |
| 791 ]); | |
| 792 | |
| 793 appDir([dependency("foo")]).scheduleCreate(); | |
| 794 | |
| 795 schedulePub(args: ['install'], | |
| 796 output: const RegExp(@"Dependencies installed!$")); | |
| 797 | |
| 798 packagesDir({ | |
| 799 "foo": "1.0.0", | |
| 800 "foo-dep": "1.0.0" | |
| 801 }).scheduleValidate(); | |
| 802 | |
| 803 servePackages([ | |
| 804 package("foo", "2.0.0", [dependency("foo-dep", ">1.0.0")]), | |
| 805 package("foo-dep", "2.0.0") | |
| 806 ]); | |
| 807 | |
| 808 schedulePub(args: ['update', 'foo'], | |
| 809 output: const RegExp(@"Dependencies updated!$")); | |
| 810 | |
| 811 packagesDir({ | |
| 812 "foo": "2.0.0", | |
| 813 "foo-dep": "2.0.0" | |
| 814 }).scheduleValidate(); | |
| 815 | |
| 816 run(); | |
| 817 }); | |
| 818 | |
| 819 test("updates a locked package's dependers in order to get it to max " | |
| 820 "version", () { | |
| 821 servePackages([ | |
| 822 package("foo", "1.0.0", [dependency("bar", "<2.0.0")]), | |
| 823 package("bar", "1.0.0") | |
| 824 ]); | |
| 825 | |
| 826 appDir([dependency("foo"), dependency("bar")]).scheduleCreate(); | |
| 827 | |
| 828 schedulePub(args: ['install'], | |
| 829 output: const RegExp(@"Dependencies installed!$")); | |
| 830 | |
| 831 packagesDir({ | |
| 832 "foo": "1.0.0", | |
| 833 "bar": "1.0.0" | |
| 834 }).scheduleValidate(); | |
| 835 | |
| 836 servePackages([ | |
| 837 package("foo", "2.0.0", [dependency("bar", "<3.0.0")]), | |
| 838 package("bar", "2.0.0") | |
| 839 ]); | |
| 840 | |
| 841 schedulePub(args: ['update', 'bar'], | |
| 842 output: const RegExp(@"Dependencies updated!$")); | |
| 843 | |
| 844 packagesDir({ | |
| 845 "foo": "2.0.0", | |
| 846 "bar": "2.0.0" | |
| 847 }).scheduleValidate(); | |
| 848 | |
| 849 run(); | |
| 850 }); | |
| 851 }); | |
| 852 } | |
| 853 | |
| 854 versionCommand() { | |
| 855 test('displays the current version', () => | 60 test('displays the current version', () => |
| 856 runPub(args: ['version'], output: VERSION_STRING)); | 61 runPub(args: ['version'], output: VERSION_STRING)); |
| 857 } | 62 } |
| OLD | NEW |