| 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 Git', () { | |
| 14 ensureGit(); | |
| 15 | |
| 16 git('foo.git', [ | |
| 17 libDir('foo'), | |
| 18 libPubspec('foo', '1.0.0') | |
| 19 ]).scheduleCreate(); | |
| 20 | |
| 21 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 22 | |
| 23 schedulePub(args: ['install'], | |
| 24 output: const RegExp(r"Dependencies installed!$")); | |
| 25 | |
| 26 dir(cachePath, [ | |
| 27 dir('git', [ | |
| 28 dir('cache', [gitPackageRepoCacheDir('foo')]), | |
| 29 gitPackageRevisionCacheDir('foo') | |
| 30 ]) | |
| 31 ]).scheduleValidate(); | |
| 32 | |
| 33 dir(packagesPath, [ | |
| 34 dir('foo', [ | |
| 35 file('foo.dart', 'main() => "foo";') | |
| 36 ]) | |
| 37 ]).scheduleValidate(); | |
| 38 | |
| 39 run(); | |
| 40 }); | |
| 41 | |
| 42 test('checks out packages transitively from Git', () { | |
| 43 ensureGit(); | |
| 44 | |
| 45 git('foo.git', [ | |
| 46 libDir('foo'), | |
| 47 libPubspec('foo', '1.0.0', [{"git": "../bar.git"}]) | |
| 48 ]).scheduleCreate(); | |
| 49 | |
| 50 git('bar.git', [ | |
| 51 libDir('bar'), | |
| 52 libPubspec('bar', '1.0.0') | |
| 53 ]).scheduleCreate(); | |
| 54 | |
| 55 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 56 | |
| 57 schedulePub(args: ['install'], | |
| 58 output: const RegExp("Dependencies installed!\$")); | |
| 59 | |
| 60 dir(cachePath, [ | |
| 61 dir('git', [ | |
| 62 dir('cache', [ | |
| 63 gitPackageRepoCacheDir('foo'), | |
| 64 gitPackageRepoCacheDir('bar') | |
| 65 ]), | |
| 66 gitPackageRevisionCacheDir('foo'), | |
| 67 gitPackageRevisionCacheDir('bar') | |
| 68 ]) | |
| 69 ]).scheduleValidate(); | |
| 70 | |
| 71 dir(packagesPath, [ | |
| 72 dir('foo', [ | |
| 73 file('foo.dart', 'main() => "foo";') | |
| 74 ]), | |
| 75 dir('bar', [ | |
| 76 file('bar.dart', 'main() => "bar";') | |
| 77 ]) | |
| 78 ]).scheduleValidate(); | |
| 79 | |
| 80 run(); | |
| 81 }); | |
| 82 | |
| 83 test('doesn\'t require the repository name to match the name in the ' | |
| 84 'pubspec', () { | |
| 85 ensureGit(); | |
| 86 | |
| 87 git('foo.git', [ | |
| 88 libDir('weirdname'), | |
| 89 libPubspec('weirdname', '1.0.0') | |
| 90 ]).scheduleCreate(); | |
| 91 | |
| 92 dir(appPath, [ | |
| 93 pubspec({ | |
| 94 "name": "myapp", | |
| 95 "dependencies": { | |
| 96 "weirdname": {"git": "../foo.git"} | |
| 97 } | |
| 98 }) | |
| 99 ]).scheduleCreate(); | |
| 100 | |
| 101 schedulePub(args: ['install'], | |
| 102 output: const RegExp(r"Dependencies installed!$")); | |
| 103 | |
| 104 dir(packagesPath, [ | |
| 105 dir('weirdname', [ | |
| 106 file('weirdname.dart', 'main() => "weirdname";') | |
| 107 ]) | |
| 108 ]).scheduleValidate(); | |
| 109 | |
| 110 run(); | |
| 111 }); | |
| 112 | |
| 113 test('requires the dependency to have a pubspec', () { | |
| 114 ensureGit(); | |
| 115 | |
| 116 git('foo.git', [ | |
| 117 libDir('foo') | |
| 118 ]).scheduleCreate(); | |
| 119 | |
| 120 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 121 | |
| 122 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is | |
| 123 // fixed. | |
| 124 schedulePub(args: ['install'], | |
| 125 error: const RegExp('^Package "foo" doesn\'t have a ' | |
| 126 'pubspec.yaml file.'), | |
| 127 exitCode: 1); | |
| 128 | |
| 129 run(); | |
| 130 }); | |
| 131 | |
| 132 test('requires the dependency to have a pubspec with a name field', () { | |
| 133 ensureGit(); | |
| 134 | |
| 135 git('foo.git', [ | |
| 136 libDir('foo'), | |
| 137 pubspec({}) | |
| 138 ]).scheduleCreate(); | |
| 139 | |
| 140 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 141 | |
| 142 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is | |
| 143 // fixed. | |
| 144 schedulePub(args: ['install'], | |
| 145 error: const RegExp(r'^Package "foo"' "'" 's pubspec.yaml file is ' | |
| 146 r'missing the required "name" field \(e\.g\. "name: foo"\)\.'), | |
| 147 exitCode: 1); | |
| 148 | |
| 149 run(); | |
| 150 }); | |
| 151 | |
| 152 test('requires the dependency name to match the remote pubspec name', () { | |
| 153 ensureGit(); | |
| 154 | |
| 155 git('foo.git', [ | |
| 156 libDir('foo'), | |
| 157 libPubspec('foo', '1.0.0') | |
| 158 ]).scheduleCreate(); | |
| 159 | |
| 160 dir(appPath, [ | |
| 161 pubspec({ | |
| 162 "name": "myapp", | |
| 163 "dependencies": { | |
| 164 "weirdname": {"git": "../foo.git"} | |
| 165 } | |
| 166 }) | |
| 167 ]).scheduleCreate(); | |
| 168 | |
| 169 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is | |
| 170 // fixed. | |
| 171 schedulePub(args: ['install'], | |
| 172 error: const RegExp(r'^The name you specified for your dependency, ' | |
| 173 '"weirdname", doesn\'t match the name "foo" in its ' | |
| 174 r'pubspec\.'), | |
| 175 exitCode: 1); | |
| 176 | |
| 177 run(); | |
| 178 }); | |
| 179 | |
| 180 test('checks out and updates a package from Git', () { | |
| 181 ensureGit(); | |
| 182 | |
| 183 git('foo.git', [ | |
| 184 libDir('foo'), | |
| 185 libPubspec('foo', '1.0.0') | |
| 186 ]).scheduleCreate(); | |
| 187 | |
| 188 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 189 | |
| 190 schedulePub(args: ['install'], | |
| 191 output: const RegExp(r"Dependencies installed!$")); | |
| 192 | |
| 193 dir(cachePath, [ | |
| 194 dir('git', [ | |
| 195 dir('cache', [gitPackageRepoCacheDir('foo')]), | |
| 196 gitPackageRevisionCacheDir('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 libDir('foo', 'foo 2'), | |
| 212 libPubspec('foo', '1.0.0') | |
| 213 ]).scheduleCommit(); | |
| 214 | |
| 215 schedulePub(args: ['install'], | |
| 216 output: const RegExp(r"Dependencies installed!$")); | |
| 217 | |
| 218 // When we download a new version of the git package, we should re-use the | |
| 219 // git/cache directory but create a new git/ directory. | |
| 220 dir(cachePath, [ | |
| 221 dir('git', [ | |
| 222 dir('cache', [gitPackageRepoCacheDir('foo')]), | |
| 223 gitPackageRevisionCacheDir('foo'), | |
| 224 gitPackageRevisionCacheDir('foo', 2) | |
| 225 ]) | |
| 226 ]).scheduleValidate(); | |
| 227 | |
| 228 dir(packagesPath, [ | |
| 229 dir('foo', [ | |
| 230 file('foo.dart', 'main() => "foo 2";') | |
| 231 ]) | |
| 232 ]).scheduleValidate(); | |
| 233 | |
| 234 run(); | |
| 235 }); | |
| 236 | |
| 237 test('checks out a package from Git twice', () { | |
| 238 ensureGit(); | |
| 239 | |
| 240 git('foo.git', [ | |
| 241 libDir('foo'), | |
| 242 libPubspec('foo', '1.0.0') | |
| 243 ]).scheduleCreate(); | |
| 244 | |
| 245 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 246 | |
| 247 schedulePub(args: ['install'], | |
| 248 output: const RegExp(r"Dependencies installed!$")); | |
| 249 | |
| 250 dir(cachePath, [ | |
| 251 dir('git', [ | |
| 252 dir('cache', [gitPackageRepoCacheDir('foo')]), | |
| 253 gitPackageRevisionCacheDir('foo') | |
| 254 ]) | |
| 255 ]).scheduleValidate(); | |
| 256 | |
| 257 dir(packagesPath, [ | |
| 258 dir('foo', [ | |
| 259 file('foo.dart', 'main() => "foo";') | |
| 260 ]) | |
| 261 ]).scheduleValidate(); | |
| 262 | |
| 263 // TODO(nweiz): remove this once we support pub update | |
| 264 dir(packagesPath).scheduleDelete(); | |
| 265 | |
| 266 // Verify that nothing breaks if we install a Git revision that's already | |
| 267 // in the cache. | |
| 268 schedulePub(args: ['install'], | |
| 269 output: const RegExp(r"Dependencies installed!$")); | |
| 270 | |
| 271 run(); | |
| 272 }); | |
| 273 | |
| 274 test('checks out a package at a specific revision from Git', () { | |
| 275 ensureGit(); | |
| 276 | |
| 277 var repo = git('foo.git', [ | |
| 278 libDir('foo', 'foo 1'), | |
| 279 libPubspec('foo', '1.0.0') | |
| 280 ]); | |
| 281 repo.scheduleCreate(); | |
| 282 var commit = repo.revParse('HEAD'); | |
| 283 | |
| 284 git('foo.git', [ | |
| 285 libDir('foo', 'foo 2'), | |
| 286 libPubspec('foo', '1.0.0') | |
| 287 ]).scheduleCommit(); | |
| 288 | |
| 289 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate(); | |
| 290 | |
| 291 schedulePub(args: ['install'], | |
| 292 output: const RegExp(r"Dependencies installed!$")); | |
| 293 | |
| 294 dir(packagesPath, [ | |
| 295 dir('foo', [ | |
| 296 file('foo.dart', 'main() => "foo 1";') | |
| 297 ]) | |
| 298 ]).scheduleValidate(); | |
| 299 | |
| 300 run(); | |
| 301 }); | |
| 302 | |
| 303 test('checks out a package at a specific branch from Git', () { | |
| 304 ensureGit(); | |
| 305 | |
| 306 var repo = git('foo.git', [ | |
| 307 libDir('foo', 'foo 1'), | |
| 308 libPubspec('foo', '1.0.0') | |
| 309 ]); | |
| 310 repo.scheduleCreate(); | |
| 311 repo.scheduleGit(["branch", "old"]); | |
| 312 | |
| 313 git('foo.git', [ | |
| 314 libDir('foo', 'foo 2'), | |
| 315 libPubspec('foo', '1.0.0') | |
| 316 ]).scheduleCommit(); | |
| 317 | |
| 318 appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).scheduleCreate(); | |
| 319 | |
| 320 schedulePub(args: ['install'], | |
| 321 output: const RegExp(r"Dependencies installed!$")); | |
| 322 | |
| 323 dir(packagesPath, [ | |
| 324 dir('foo', [ | |
| 325 file('foo.dart', 'main() => "foo 1";') | |
| 326 ]) | |
| 327 ]).scheduleValidate(); | |
| 328 | |
| 329 run(); | |
| 330 }); | |
| 331 | |
| 332 test('keeps a Git package locked to the version in the lockfile', () { | |
| 333 ensureGit(); | |
| 334 | |
| 335 git('foo.git', [ | |
| 336 libDir('foo'), | |
| 337 libPubspec('foo', '1.0.0') | |
| 338 ]).scheduleCreate(); | |
| 339 | |
| 340 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 341 | |
| 342 // This install should lock the foo.git dependency to the current revision. | |
| 343 schedulePub(args: ['install'], | |
| 344 output: const RegExp(r"Dependencies installed!$")); | |
| 345 | |
| 346 dir(packagesPath, [ | |
| 347 dir('foo', [ | |
| 348 file('foo.dart', 'main() => "foo";') | |
| 349 ]) | |
| 350 ]).scheduleValidate(); | |
| 351 | |
| 352 // Delete the packages path to simulate a new checkout of the application. | |
| 353 dir(packagesPath).scheduleDelete(); | |
| 354 | |
| 355 git('foo.git', [ | |
| 356 libDir('foo', 'foo 2'), | |
| 357 libPubspec('foo', '1.0.0') | |
| 358 ]).scheduleCommit(); | |
| 359 | |
| 360 // This install shouldn't update the foo.git dependency due to the lockfile. | |
| 361 schedulePub(args: ['install'], | |
| 362 output: const RegExp(r"Dependencies installed!$")); | |
| 363 | |
| 364 dir(packagesPath, [ | |
| 365 dir('foo', [ | |
| 366 file('foo.dart', 'main() => "foo";') | |
| 367 ]) | |
| 368 ]).scheduleValidate(); | |
| 369 | |
| 370 run(); | |
| 371 }); | |
| 372 | |
| 373 test('updates a locked Git package with a new incompatible constraint', () { | |
| 374 ensureGit(); | |
| 375 | |
| 376 git('foo.git', [ | |
| 377 libDir('foo'), | |
| 378 libPubspec('foo', '0.5.0') | |
| 379 ]).scheduleCreate(); | |
| 380 | |
| 381 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 382 | |
| 383 schedulePub(args: ['install'], | |
| 384 output: const RegExp(r"Dependencies installed!$")); | |
| 385 | |
| 386 dir(packagesPath, [ | |
| 387 dir('foo', [ | |
| 388 file('foo.dart', 'main() => "foo";') | |
| 389 ]) | |
| 390 ]).scheduleValidate(); | |
| 391 | |
| 392 git('foo.git', [ | |
| 393 libDir('foo', 'foo 1.0.0'), | |
| 394 libPubspec("foo", "1.0.0") | |
| 395 ]).scheduleCommit(); | |
| 396 | |
| 397 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); | |
| 398 | |
| 399 schedulePub(args: ['install'], | |
| 400 output: const RegExp(r"Dependencies installed!$")); | |
| 401 | |
| 402 dir(packagesPath, [ | |
| 403 dir('foo', [ | |
| 404 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 405 ]) | |
| 406 ]).scheduleValidate(); | |
| 407 | |
| 408 run(); | |
| 409 }); | |
| 410 | |
| 411 test("doesn't update a locked Git package with a new compatible " | |
| 412 "constraint", () { | |
| 413 ensureGit(); | |
| 414 | |
| 415 git('foo.git', [ | |
| 416 libDir('foo', 'foo 1.0.0'), | |
| 417 libPubspec("foo", "1.0.0") | |
| 418 ]).scheduleCreate(); | |
| 419 | |
| 420 appDir([{"git": "../foo.git"}]).scheduleCreate(); | |
| 421 | |
| 422 schedulePub(args: ['install'], | |
| 423 output: const RegExp(r"Dependencies installed!$")); | |
| 424 | |
| 425 dir(packagesPath, [ | |
| 426 dir('foo', [ | |
| 427 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 428 ]) | |
| 429 ]).scheduleValidate(); | |
| 430 | |
| 431 git('foo.git', [ | |
| 432 libDir('foo', 'foo 1.0.1'), | |
| 433 libPubspec("foo", "1.0.1") | |
| 434 ]).scheduleCommit(); | |
| 435 | |
| 436 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); | |
| 437 | |
| 438 schedulePub(args: ['install'], | |
| 439 output: const RegExp(r"Dependencies installed!$")); | |
| 440 | |
| 441 dir(packagesPath, [ | |
| 442 dir('foo', [ | |
| 443 file('foo.dart', 'main() => "foo 1.0.0";') | |
| 444 ]) | |
| 445 ]).scheduleValidate(); | |
| 446 | |
| 447 run(); | |
| 448 }); | |
| 449 | |
| 450 group("(regression)", () { | |
| 451 test('checks out a package from Git with a trailing slash', () { | |
| 452 ensureGit(); | |
| 453 | |
| 454 git('foo.git', [ | |
| 455 libDir('foo'), | |
| 456 libPubspec('foo', '1.0.0') | |
| 457 ]).scheduleCreate(); | |
| 458 | |
| 459 appDir([{"git": "../foo.git/"}]).scheduleCreate(); | |
| 460 | |
| 461 schedulePub(args: ['install'], | |
| 462 output: const RegExp(r"Dependencies installed!$")); | |
| 463 | |
| 464 dir(cachePath, [ | |
| 465 dir('git', [ | |
| 466 dir('cache', [gitPackageRepoCacheDir('foo')]), | |
| 467 gitPackageRevisionCacheDir('foo') | |
| 468 ]) | |
| 469 ]).scheduleValidate(); | |
| 470 | |
| 471 dir(packagesPath, [ | |
| 472 dir('foo', [ | |
| 473 file('foo.dart', 'main() => "foo";') | |
| 474 ]) | |
| 475 ]).scheduleValidate(); | |
| 476 | |
| 477 run(); | |
| 478 }); | |
| 479 }); | |
| 480 } | |
| OLD | NEW |