| 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('../../../lib/unittest/unittest.dart'); | 10 #import('../../../lib/unittest/unittest.dart'); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 dir(packagesPath, [ | 110 dir(packagesPath, [ |
| 111 dir('foo', [ | 111 dir('foo', [ |
| 112 file('foo.dart', 'main() => "foo";') | 112 file('foo.dart', 'main() => "foo";') |
| 113 ]) | 113 ]) |
| 114 ]).scheduleValidate(); | 114 ]).scheduleValidate(); |
| 115 | 115 |
| 116 run(); | 116 run(); |
| 117 }); | 117 }); |
| 118 | 118 |
| 119 test('checks out a package from Git', () { | 119 test('checks out a package from Git', () { |
| 120 withGit(() { | 120 ensureGit(); |
| 121 git('foo.git', [ | 121 |
| 122 file('foo.dart', 'main() => "foo";') | 122 git('foo.git', [ |
| 123 ]).scheduleCreate(); | 123 file('foo.dart', 'main() => "foo";') |
| 124 | 124 ]).scheduleCreate(); |
| 125 dir(appPath, [ | 125 |
| 126 file('pubspec.yaml', ''' | 126 dir(appPath, [ |
| 127 dependencies: | 127 file('pubspec.yaml', ''' |
| 128 foo: | 128 dependencies: |
| 129 git: ../foo.git | 129 foo: |
| 130 ''') | 130 git: ../foo.git |
| 131 ]).scheduleCreate(); | 131 ''') |
| 132 | 132 ]).scheduleCreate(); |
| 133 schedulePub(args: ['install'], | 133 |
| 134 output: const RegExp(@"Dependencies installed!$")); | 134 schedulePub(args: ['install'], |
| 135 | 135 output: const RegExp(@"Dependencies installed!$")); |
| 136 dir(cachePath, [ | 136 |
| 137 dir('git', [ | 137 dir(cachePath, [ |
| 138 dir('cache', [ | 138 dir('git', [ |
| 139 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 139 dir('cache', [ |
| 140 file('foo.dart', 'main() => "foo";') | 140 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 141 ]) | 141 file('foo.dart', 'main() => "foo";') |
| 142 ]), | 142 ]) |
| 143 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 143 ]), |
| 144 file('foo.dart', 'main() => "foo";') | 144 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 145 ]) | 145 file('foo.dart', 'main() => "foo";') |
| 146 ]) | 146 ]) |
| 147 ]).scheduleValidate(); | 147 ]) |
| 148 | 148 ]).scheduleValidate(); |
| 149 dir(packagesPath, [ | 149 |
| 150 dir('foo', [ | 150 dir(packagesPath, [ |
| 151 file('foo.dart', 'main() => "foo";') | 151 dir('foo', [ |
| 152 ]) | 152 file('foo.dart', 'main() => "foo";') |
| 153 ]).scheduleValidate(); | 153 ]) |
| 154 | 154 ]).scheduleValidate(); |
| 155 run(); | 155 |
| 156 }); | 156 run(); |
| 157 }); | 157 }); |
| 158 | 158 |
| 159 test('checks out packages transitively from Git', () { | 159 test('checks out packages transitively from Git', () { |
| 160 withGit(() { | 160 ensureGit(); |
| 161 git('foo.git', [ | 161 |
| 162 file('foo.dart', 'main() => "foo";'), | 162 git('foo.git', [ |
| 163 file('pubspec.yaml', ''' | 163 file('foo.dart', 'main() => "foo";'), |
| 164 file('pubspec.yaml', ''' |
| 164 dependencies: | 165 dependencies: |
| 165 bar: | 166 bar: |
| 166 git: ../bar.git | 167 git: ../bar.git |
| 167 ''') | 168 ''') |
| 168 ]).scheduleCreate(); | 169 ]).scheduleCreate(); |
| 169 | 170 |
| 170 git('bar.git', [ | 171 git('bar.git', [ |
| 171 file('bar.dart', 'main() => "bar";') | 172 file('bar.dart', 'main() => "bar";') |
| 172 ]).scheduleCreate(); | 173 ]).scheduleCreate(); |
| 173 | 174 |
| 174 dir(appPath, [ | 175 dir(appPath, [ |
| 175 file('pubspec.yaml', ''' | 176 file('pubspec.yaml', ''' |
| 176 dependencies: | 177 dependencies: |
| 177 foo: | 178 foo: |
| 178 git: ../foo.git | 179 git: ../foo.git |
| 179 ''') | 180 ''') |
| 180 ]).scheduleCreate(); | 181 ]).scheduleCreate(); |
| 181 | 182 |
| 182 schedulePub(args: ['install'], | 183 schedulePub(args: ['install'], |
| 183 output: const RegExp("Dependencies installed!\$")); | 184 output: const RegExp("Dependencies installed!\$")); |
| 184 | 185 |
| 185 dir(cachePath, [ | 186 dir(cachePath, [ |
| 186 dir('git', [ | 187 dir('git', [ |
| 187 dir('cache', [ | 188 dir('cache', [ |
| 188 dir(new RegExp(@'foo-[a-f0-9]+'), [ | |
| 189 file('foo.dart', 'main() => "foo";') | |
| 190 ]), | |
| 191 dir(new RegExp(@'bar-[a-f0-9]+'), [ | |
| 192 file('bar.dart', 'main() => "bar";') | |
| 193 ]) | |
| 194 ]), | |
| 195 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 189 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 196 file('foo.dart', 'main() => "foo";') | 190 file('foo.dart', 'main() => "foo";') |
| 197 ]), | 191 ]), |
| 198 dir(new RegExp(@'bar-[a-f0-9]+'), [ | 192 dir(new RegExp(@'bar-[a-f0-9]+'), [ |
| 199 file('bar.dart', 'main() => "bar";') | 193 file('bar.dart', 'main() => "bar";') |
| 200 ]) | 194 ]) |
| 201 ]) | 195 ]), |
| 202 ]).scheduleValidate(); | 196 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 203 | 197 file('foo.dart', 'main() => "foo";') |
| 204 dir(packagesPath, [ | 198 ]), |
| 205 dir('foo', [ | 199 dir(new RegExp(@'bar-[a-f0-9]+'), [ |
| 206 file('foo.dart', 'main() => "foo";') | |
| 207 ]), | |
| 208 dir('bar', [ | |
| 209 file('bar.dart', 'main() => "bar";') | 200 file('bar.dart', 'main() => "bar";') |
| 210 ]) | 201 ]) |
| 211 ]).scheduleValidate(); | 202 ]) |
| 212 | 203 ]).scheduleValidate(); |
| 213 run(); | 204 |
| 214 }); | 205 dir(packagesPath, [ |
| 206 dir('foo', [ |
| 207 file('foo.dart', 'main() => "foo";') |
| 208 ]), |
| 209 dir('bar', [ |
| 210 file('bar.dart', 'main() => "bar";') |
| 211 ]) |
| 212 ]).scheduleValidate(); |
| 213 |
| 214 run(); |
| 215 }); | 215 }); |
| 216 | 216 |
| 217 test('checks out and updates a package from Git', () { | 217 test('checks out and updates a package from Git', () { |
| 218 withGit(() { | 218 ensureGit(); |
| 219 git('foo.git', [ | 219 |
| 220 file('foo.dart', 'main() => "foo";') | 220 git('foo.git', [ |
| 221 ]).scheduleCreate(); | 221 file('foo.dart', 'main() => "foo";') |
| 222 | 222 ]).scheduleCreate(); |
| 223 dir(appPath, [ | 223 |
| 224 file('pubspec.yaml', ''' | 224 dir(appPath, [ |
| 225 dependencies: | 225 file('pubspec.yaml', ''' |
| 226 foo: | 226 dependencies: |
| 227 git: ../foo.git | 227 foo: |
| 228 ''') | 228 git: ../foo.git |
| 229 ]).scheduleCreate(); | 229 ''') |
| 230 | 230 ]).scheduleCreate(); |
| 231 schedulePub(args: ['install'], | 231 |
| 232 output: const RegExp(@"Dependencies installed!$")); | 232 schedulePub(args: ['install'], |
| 233 | 233 output: const RegExp(@"Dependencies installed!$")); |
| 234 dir(cachePath, [ | 234 |
| 235 dir('git', [ | 235 dir(cachePath, [ |
| 236 dir('cache', [ | 236 dir('git', [ |
| 237 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 237 dir('cache', [ |
| 238 file('foo.dart', 'main() => "foo";') | 238 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 239 ]) | 239 file('foo.dart', 'main() => "foo";') |
| 240 ]), | 240 ]) |
| 241 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 241 ]), |
| 242 file('foo.dart', 'main() => "foo";') | 242 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 243 ]) | 243 file('foo.dart', 'main() => "foo";') |
| 244 ]) | 244 ]) |
| 245 ]).scheduleValidate(); | 245 ]) |
| 246 | 246 ]).scheduleValidate(); |
| 247 dir(packagesPath, [ | 247 |
| 248 dir('foo', [ | 248 dir(packagesPath, [ |
| 249 file('foo.dart', 'main() => "foo";') | 249 dir('foo', [ |
| 250 ]) | 250 file('foo.dart', 'main() => "foo";') |
| 251 ]).scheduleValidate(); | 251 ]) |
| 252 | 252 ]).scheduleValidate(); |
| 253 // TODO(nweiz): remove this once we support pub update | 253 |
| 254 dir(packagesPath).scheduleDelete(); | 254 // TODO(nweiz): remove this once we support pub update |
| 255 | 255 dir(packagesPath).scheduleDelete(); |
| 256 git('foo.git', [ | 256 |
| 257 git('foo.git', [ |
| 258 file('foo.dart', 'main() => "foo 2";') |
| 259 ]).scheduleCommit(); |
| 260 |
| 261 schedulePub(args: ['install'], |
| 262 output: const RegExp(@"Dependencies installed!$")); |
| 263 |
| 264 // When we download a new version of the git package, we should re-use the |
| 265 // git/cache directory but create a new git/ directory. |
| 266 dir(cachePath, [ |
| 267 dir('git', [ |
| 268 dir('cache', [ |
| 269 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 270 file('foo.dart', 'main() => "foo 2";') |
| 271 ]) |
| 272 ]), |
| 273 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 274 file('foo.dart', 'main() => "foo";') |
| 275 ]), |
| 276 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 277 file('foo.dart', 'main() => "foo 2";') |
| 278 ]) |
| 279 ]) |
| 280 ]).scheduleValidate(); |
| 281 |
| 282 dir(packagesPath, [ |
| 283 dir('foo', [ |
| 257 file('foo.dart', 'main() => "foo 2";') | 284 file('foo.dart', 'main() => "foo 2";') |
| 258 ]).scheduleCommit(); | 285 ]) |
| 259 | 286 ]).scheduleValidate(); |
| 260 schedulePub(args: ['install'], | 287 |
| 261 output: const RegExp(@"Dependencies installed!$")); | 288 run(); |
| 262 | |
| 263 // When we download a new version of the git package, we should re-use the | |
| 264 // git/cache directory but create a new git/ directory. | |
| 265 dir(cachePath, [ | |
| 266 dir('git', [ | |
| 267 dir('cache', [ | |
| 268 dir(new RegExp(@'foo-[a-f0-9]+'), [ | |
| 269 file('foo.dart', 'main() => "foo 2";') | |
| 270 ]) | |
| 271 ]), | |
| 272 dir(new RegExp(@'foo-[a-f0-9]+'), [ | |
| 273 file('foo.dart', 'main() => "foo";') | |
| 274 ]), | |
| 275 dir(new RegExp(@'foo-[a-f0-9]+'), [ | |
| 276 file('foo.dart', 'main() => "foo 2";') | |
| 277 ]) | |
| 278 ]) | |
| 279 ]).scheduleValidate(); | |
| 280 | |
| 281 dir(packagesPath, [ | |
| 282 dir('foo', [ | |
| 283 file('foo.dart', 'main() => "foo 2";') | |
| 284 ]) | |
| 285 ]).scheduleValidate(); | |
| 286 | |
| 287 run(); | |
| 288 }); | |
| 289 }); | 289 }); |
| 290 | 290 |
| 291 test('checks out a package from Git twice', () { | 291 test('checks out a package from Git twice', () { |
| 292 withGit(() { | 292 ensureGit(); |
| 293 git('foo.git', [ | 293 |
| 294 file('foo.dart', 'main() => "foo";') | 294 git('foo.git', [ |
| 295 ]).scheduleCreate(); | 295 file('foo.dart', 'main() => "foo";') |
| 296 | 296 ]).scheduleCreate(); |
| 297 dir(appPath, [ | 297 |
| 298 file('pubspec.yaml', ''' | 298 dir(appPath, [ |
| 299 dependencies: | 299 file('pubspec.yaml', ''' |
| 300 foo: | 300 dependencies: |
| 301 git: ../foo.git | 301 foo: |
| 302 ''') | 302 git: ../foo.git |
| 303 ]).scheduleCreate(); | 303 ''') |
| 304 | 304 ]).scheduleCreate(); |
| 305 schedulePub(args: ['install'], | 305 |
| 306 output: const RegExp(@"Dependencies installed!$")); | 306 schedulePub(args: ['install'], |
| 307 | 307 output: const RegExp(@"Dependencies installed!$")); |
| 308 dir(cachePath, [ | 308 |
| 309 dir('git', [ | 309 dir(cachePath, [ |
| 310 dir('cache', [ | 310 dir('git', [ |
| 311 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 311 dir('cache', [ |
| 312 file('foo.dart', 'main() => "foo";') | 312 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 313 ]) | 313 file('foo.dart', 'main() => "foo";') |
| 314 ]), | 314 ]) |
| 315 dir(new RegExp(@'foo-[a-f0-9]+'), [ | 315 ]), |
| 316 file('foo.dart', 'main() => "foo";') | 316 dir(new RegExp(@'foo-[a-f0-9]+'), [ |
| 317 ]) | 317 file('foo.dart', 'main() => "foo";') |
| 318 ]) | 318 ]) |
| 319 ]).scheduleValidate(); | 319 ]) |
| 320 | 320 ]).scheduleValidate(); |
| 321 dir(packagesPath, [ | 321 |
| 322 dir('foo', [ | 322 dir(packagesPath, [ |
| 323 file('foo.dart', 'main() => "foo";') | 323 dir('foo', [ |
| 324 ]) | 324 file('foo.dart', 'main() => "foo";') |
| 325 ]).scheduleValidate(); | 325 ]) |
| 326 | 326 ]).scheduleValidate(); |
| 327 // TODO(nweiz): remove this once we support pub update | 327 |
| 328 dir(packagesPath).scheduleDelete(); | 328 // TODO(nweiz): remove this once we support pub update |
| 329 | 329 dir(packagesPath).scheduleDelete(); |
| 330 // Verify that nothing breaks if we install a Git revision that's already | 330 |
| 331 // in the cache. | 331 // Verify that nothing breaks if we install a Git revision that's already |
| 332 schedulePub(args: ['install'], | 332 // in the cache. |
| 333 output: const RegExp(@"Dependencies installed!$")); | 333 schedulePub(args: ['install'], |
| 334 | 334 output: const RegExp(@"Dependencies installed!$")); |
| 335 run(); | 335 |
| 336 }); | 336 run(); |
| 337 }); |
| 338 |
| 339 test('checks out a package at a specific revision from Git', () { |
| 340 ensureGit(); |
| 341 |
| 342 var repo = git('foo.git', [ |
| 343 file('foo.dart', 'main() => "foo 1";') |
| 344 ]); |
| 345 repo.scheduleCreate(); |
| 346 var commitFuture = repo.revParse('HEAD'); |
| 347 |
| 348 git('foo.git', [ |
| 349 file('foo.dart', 'main() => "foo 2";') |
| 350 ]).scheduleCommit(); |
| 351 |
| 352 dir(appPath, [ |
| 353 async(commitFuture.transform((commit) { |
| 354 return file('pubspec.yaml', ''' |
| 355 dependencies: |
| 356 foo: |
| 357 git: |
| 358 url: ../foo.git |
| 359 ref: $commit |
| 360 '''); |
| 361 })) |
| 362 ]).scheduleCreate(); |
| 363 |
| 364 schedulePub(args: ['install'], |
| 365 output: const RegExp(@"Dependencies installed!$")); |
| 366 |
| 367 dir(packagesPath, [ |
| 368 dir('foo', [ |
| 369 file('foo.dart', 'main() => "foo 1";') |
| 370 ]) |
| 371 ]).scheduleValidate(); |
| 372 |
| 373 run(); |
| 337 }); | 374 }); |
| 338 | 375 |
| 339 test('checks out a package from a pub server', () { | 376 test('checks out a package from a pub server', () { |
| 340 servePackages("localhost", 3123, ['{name: foo, version: 1.2.3}']); | 377 servePackages("localhost", 3123, ['{name: foo, version: 1.2.3}']); |
| 341 | 378 |
| 342 dir(appPath, [ | 379 dir(appPath, [ |
| 343 file('pubspec.yaml', ''' | 380 file('pubspec.yaml', ''' |
| 344 dependencies: | 381 dependencies: |
| 345 foo: | 382 foo: |
| 346 repo: | 383 repo: |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 ]).scheduleValidate(); | 580 ]).scheduleValidate(); |
| 544 | 581 |
| 545 run(); | 582 run(); |
| 546 }); | 583 }); |
| 547 } | 584 } |
| 548 | 585 |
| 549 versionCommand() { | 586 versionCommand() { |
| 550 test('displays the current version', () => | 587 test('displays the current version', () => |
| 551 runPub(args: ['version'], output: VERSION_STRING)); | 588 runPub(args: ['version'], output: VERSION_STRING)); |
| 552 } | 589 } |
| OLD | NEW |