| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Smoke tests for gclient.py. | 6 """Smoke tests for gclient.py. |
| 7 | 7 |
| 8 Shell out 'gclient' and run basic conformance tests. | 8 Shell out 'gclient' and run basic conformance tests. |
| 9 | 9 |
| 10 This test assumes GClientSmokeBase.URL_BASE is valid. | 10 This test assumes GClientSmokeBase.URL_BASE is valid. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 results = self.gclient(['config', 'foo', 'faa', 'fuu']) | 202 results = self.gclient(['config', 'foo', 'faa', 'fuu']) |
| 203 err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n' | 203 err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n' |
| 204 'gclient.py: error: Inconsistent arguments. Use either --spec or one' | 204 'gclient.py: error: Inconsistent arguments. Use either --spec or one' |
| 205 ' or 2 args\n') | 205 ' or 2 args\n') |
| 206 self.check(('', err, 2), results) | 206 self.check(('', err, 2), results) |
| 207 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) | 207 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) |
| 208 | 208 |
| 209 | 209 |
| 210 class GClientSmokeSVN(GClientSmokeBase): | 210 class GClientSmokeSVN(GClientSmokeBase): |
| 211 def testSync(self): | 211 def testSync(self): |
| 212 # TODO(maruel): safesync, multiple solutions, invalid@revisions, | 212 # TODO(maruel): safesync. |
| 213 # multiple revisions. | |
| 214 self.gclient(['config', self.svn_base + 'trunk/src/']) | 213 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 215 # Test unversioned checkout. | 214 # Test unversioned checkout. |
| 216 results = self.gclient(['sync', '--deps', 'mac']) | 215 results = self.gclient(['sync', '--deps', 'mac']) |
| 217 logging.debug(results[0]) | 216 logging.debug(results[0]) |
| 218 out = results[0].splitlines(False) | 217 out = results[0].splitlines(False) |
| 219 self.assertEquals(17, len(out)) | 218 self.assertEquals(17, len(out)) |
| 220 self.checkString('', results[1]) | 219 self.checkString('', results[1]) |
| 221 self.assertEquals(0, results[2]) | 220 self.assertEquals(0, results[2]) |
| 222 tree = mangle_svn_tree( | 221 tree = mangle_svn_tree( |
| 223 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), | 222 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), |
| 224 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 223 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
| 225 FAKE.svn_revs[1]), | 224 FAKE.svn_revs[1]), |
| 226 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), | 225 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 227 ) | 226 ) |
| 228 tree[join('src', 'hooked1')] = 'hooked1' | 227 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
| 229 self.assertTree(tree) | 228 self.assertTree(tree) |
| 230 | 229 |
| 231 # Manually remove hooked1 before synching to make sure it's not recreated. | 230 # Manually remove svn_hooked1 before synching to make sure it's not |
| 232 os.remove(join(self.root_dir, 'src', 'hooked1')) | 231 # recreated. |
| 232 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) |
| 233 | 233 |
| 234 # Test incremental versioned sync: sync backward. | 234 # Test incremental versioned sync: sync backward. |
| 235 results = self.gclient(['sync', '--revision', 'src@1', '--deps', 'mac', | 235 results = self.gclient(['sync', '--revision', 'src@1', '--deps', 'mac', |
| 236 '--delete_unversioned_trees']) | 236 '--delete_unversioned_trees']) |
| 237 logging.debug(results[0]) | 237 logging.debug(results[0]) |
| 238 out = results[0].splitlines(False) | 238 out = results[0].splitlines(False) |
| 239 self.assertEquals(19, len(out)) | 239 self.assertEquals(19, len(out)) |
| 240 self.checkString('', results[1]) | 240 self.checkString('', results[1]) |
| 241 self.assertEquals(0, results[2]) | 241 self.assertEquals(0, results[2]) |
| 242 tree = mangle_svn_tree( | 242 tree = mangle_svn_tree( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 260 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), | 260 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), |
| 261 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 261 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), |
| 262 FAKE.svn_revs[2]), | 262 FAKE.svn_revs[2]), |
| 263 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 263 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
| 264 FAKE.svn_revs[1]), | 264 FAKE.svn_revs[1]), |
| 265 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), | 265 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 266 (join('trunk', 'third_party', 'foo'), | 266 (join('trunk', 'third_party', 'foo'), |
| 267 join('src', 'third_party', 'prout'), | 267 join('src', 'third_party', 'prout'), |
| 268 FAKE.svn_revs[2]), | 268 FAKE.svn_revs[2]), |
| 269 ) | 269 ) |
| 270 tree[join('src', 'hooked1')] = 'hooked1' | 270 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
| 271 self.assertTree(tree) | 271 self.assertTree(tree) |
| 272 | 272 |
| 273 def SyncAtRev1(self, arg): |
| 274 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 275 results = self.gclient(['sync', '--deps', 'mac', '-r', arg]) |
| 276 out = results[0].splitlines(False) |
| 277 self.assertEquals(19, len(out)) |
| 278 self.checkString('', results[1]) |
| 279 self.assertEquals(0, results[2]) |
| 280 tree = mangle_svn_tree( |
| 281 (join('trunk', 'src'), 'src', FAKE.svn_revs[1]), |
| 282 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), |
| 283 FAKE.svn_revs[2]), |
| 284 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 285 (join('trunk', 'third_party', 'foo'), |
| 286 join('src', 'third_party', 'prout'), |
| 287 FAKE.svn_revs[2]), |
| 288 ) |
| 289 self.assertTree(tree) |
| 290 |
| 291 def testSyncIgnoredSolutionName(self): |
| 292 self.SyncAtRev1('ignored@1') |
| 293 |
| 294 def testSyncNoSolutionName(self): |
| 295 self.SyncAtRev1('1') |
| 296 |
| 273 def testRevertAndStatus(self): | 297 def testRevertAndStatus(self): |
| 274 self.gclient(['config', self.svn_base + 'trunk/src/']) | 298 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 275 # Tested in testSync. | 299 # Tested in testSync. |
| 276 self.gclient(['sync', '--deps', 'mac']) | 300 self.gclient(['sync', '--deps', 'mac']) |
| 277 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 301 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
| 278 | 302 |
| 279 results = self.gclient(['status']) | 303 results = self.gclient(['status']) |
| 280 out = results[0].splitlines(False) | 304 out = results[0].splitlines(False) |
| 281 self.assertEquals(out[0], '') | 305 self.assertEquals(out[0], '') |
| 282 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 306 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 283 self.assertEquals(out[2], '? other') | 307 self.assertEquals(out[2], '? svn_hooked1') |
| 284 self.assertEquals(out[3], '? hooked1') | 308 self.assertEquals(out[3], '? other') |
| 285 self.assertEquals(out[4], '? third_party/foo') | 309 self.assertEquals(out[4], '? third_party/foo') |
| 286 self.assertEquals(out[5], '') | 310 self.assertEquals(out[5], '') |
| 287 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) | 311 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) |
| 288 self.assertEquals(out[7], '? hi') | 312 self.assertEquals(out[7], '? hi') |
| 289 self.assertEquals(8, len(out)) | 313 self.assertEquals(8, len(out)) |
| 290 self.assertEquals('', results[1]) | 314 self.assertEquals('', results[1]) |
| 291 self.assertEquals(0, results[2]) | 315 self.assertEquals(0, results[2]) |
| 292 | 316 |
| 293 # Revert implies --force implies running hooks without looking at pattern | 317 # Revert implies --force implies running hooks without looking at pattern |
| 294 # matching. | 318 # matching. |
| 295 results = self.gclient(['revert']) | 319 results = self.gclient(['revert']) |
| 296 out = results[0].splitlines(False) | 320 out = results[0].splitlines(False) |
| 297 self.assertEquals(22, len(out)) | 321 self.assertEquals(22, len(out)) |
| 298 self.checkString('', results[1]) | 322 self.checkString('', results[1]) |
| 299 self.assertEquals(0, results[2]) | 323 self.assertEquals(0, results[2]) |
| 300 tree = mangle_svn_tree( | 324 tree = mangle_svn_tree( |
| 301 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), | 325 (join('trunk', 'src'), 'src', FAKE.svn_revs[-1]), |
| 302 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 326 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
| 303 FAKE.svn_revs[1]), | 327 FAKE.svn_revs[1]), |
| 304 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), | 328 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 305 ) | 329 ) |
| 306 tree[join('src', 'hooked1')] = 'hooked1' | 330 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
| 307 tree[join('src', 'hooked2')] = 'hooked2' | 331 tree[join('src', 'svn_hooked2')] = 'svn_hooked2' |
| 308 self.assertTree(tree) | 332 self.assertTree(tree) |
| 309 | 333 |
| 310 results = self.gclient(['status']) | 334 results = self.gclient(['status']) |
| 311 out = results[0].splitlines(False) | 335 out = results[0].splitlines(False) |
| 312 self.assertEquals(out[0], '') | 336 self.assertEquals(out[0], '') |
| 313 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 337 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 314 self.assertEquals(out[2], '? other') | 338 self.assertEquals(out[2], '? svn_hooked1') |
| 315 self.assertEquals(out[3], '? hooked1') | 339 self.assertEquals(out[3], '? svn_hooked2') |
| 316 self.assertEquals(out[4], '? hooked2') | 340 self.assertEquals(out[4], '? other') |
| 317 self.assertEquals(out[5], '? third_party/foo') | 341 self.assertEquals(out[5], '? third_party/foo') |
| 318 self.assertEquals(6, len(out)) | 342 self.assertEquals(6, len(out)) |
| 319 self.checkString('', results[1]) | 343 self.checkString('', results[1]) |
| 320 self.assertEquals(0, results[2]) | 344 self.assertEquals(0, results[2]) |
| 321 | 345 |
| 322 def testRevertAndStatusDepsOs(self): | 346 def testRevertAndStatusDepsOs(self): |
| 323 self.gclient(['config', self.svn_base + 'trunk/src/']) | 347 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 324 # Tested in testSync. | 348 # Tested in testSync. |
| 325 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 349 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 326 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 350 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 self.assertEquals(0, results[2]) | 393 self.assertEquals(0, results[2]) |
| 370 | 394 |
| 371 def testRunHooks(self): | 395 def testRunHooks(self): |
| 372 self.gclient(['config', self.svn_base + 'trunk/src/']) | 396 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 373 self.gclient(['sync', '--deps', 'mac']) | 397 self.gclient(['sync', '--deps', 'mac']) |
| 374 results = self.gclient(['runhooks']) | 398 results = self.gclient(['runhooks']) |
| 375 out = results[0].splitlines(False) | 399 out = results[0].splitlines(False) |
| 376 self.assertEquals(4, len(out)) | 400 self.assertEquals(4, len(out)) |
| 377 self.assertEquals(out[0], '') | 401 self.assertEquals(out[0], '') |
| 378 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 402 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 379 r'open\(\'src/hooked1\', \'w\'\)\.write\(\'hooked1\'\)\' in \'.*', | 403 r'open\(\'src/svn_hooked1\', \'w\'\)\.write\(\'svn_hooked1\'\)\' in \'.*', |
| 380 out[1])) | 404 out[1])) |
| 381 self.assertEquals(out[2], '') | 405 self.assertEquals(out[2], '') |
| 382 # runhooks runs all hooks even if not matching by design. | 406 # runhooks runs all hooks even if not matching by design. |
| 383 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 407 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 384 r'open\(\'src/hooked2\', \'w\'\)\.write\(\'hooked2\'\)\' in \'.*', | 408 r'open\(\'src/svn_hooked2\', \'w\'\)\.write\(\'svn_hooked2\'\)\' in \'.*', |
| 385 out[3])) | 409 out[3])) |
| 386 self.checkString('', results[1]) | 410 self.checkString('', results[1]) |
| 387 self.assertEquals(0, results[2]) | 411 self.assertEquals(0, results[2]) |
| 388 | 412 |
| 389 def testRunHooks(self): | 413 def testRunHooks(self): |
| 390 self.gclient(['config', self.svn_base + 'trunk/src/']) | 414 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 391 self.gclient(['sync', '--deps', 'mac']) | 415 self.gclient(['sync', '--deps', 'mac']) |
| 392 results = self.gclient(['runhooks']) | 416 results = self.gclient(['runhooks']) |
| 393 out = results[0].splitlines(False) | 417 out = results[0].splitlines(False) |
| 394 self.assertEquals(4, len(out)) | 418 self.assertEquals(4, len(out)) |
| 395 self.assertEquals(out[0], '') | 419 self.assertEquals(out[0], '') |
| 396 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 420 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 397 r'open\(\'src/hooked1\', \'w\'\)\.write\(\'hooked1\'\)\' in \'.*', | 421 r'open\(\'src/svn_hooked1\', \'w\'\)\.write\(\'svn_hooked1\'\)\' in \'.*', |
| 398 out[1])) | 422 out[1])) |
| 399 self.assertEquals(out[2], '') | 423 self.assertEquals(out[2], '') |
| 400 # runhooks runs all hooks even if not matching by design. | 424 # runhooks runs all hooks even if not matching by design. |
| 401 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 425 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 402 r'open\(\'src/hooked2\', \'w\'\)\.write\(\'hooked2\'\)\' in \'.*', | 426 r'open\(\'src/svn_hooked2\', \'w\'\)\.write\(\'svn_hooked2\'\)\' in \'.*', |
| 403 out[3])) | 427 out[3])) |
| 404 self.checkString('', results[1]) | 428 self.checkString('', results[1]) |
| 405 self.assertEquals(0, results[2]) | 429 self.assertEquals(0, results[2]) |
| 406 | 430 |
| 407 def testRunHooksDepsOs(self): | 431 def testRunHooksDepsOs(self): |
| 408 self.gclient(['config', self.svn_base + 'trunk/src/']) | 432 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 409 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 433 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 410 results = self.gclient(['runhooks']) | 434 results = self.gclient(['runhooks']) |
| 411 self.check(('', '', 0), results) | 435 self.check(('', '', 0), results) |
| 412 | 436 |
| 413 def testRevInfo(self): | 437 def testRevInfo(self): |
| 414 # TODO(maruel): Test multiple solutions. | 438 # TODO(maruel): Test multiple solutions. |
| 415 self.gclient(['config', self.svn_base + 'trunk/src/']) | 439 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 416 self.gclient(['sync', '--deps', 'mac']) | 440 self.gclient(['sync', '--deps', 'mac']) |
| 417 results = self.gclient(['revinfo']) | 441 results = self.gclient(['revinfo']) |
| 418 out = ('src: %(base)s/src@2;\n' | 442 out = ('src: %(base)s/src@2;\n' |
| 419 'src/other: %(base)s/other@2;\n' | 443 'src/other: %(base)s/other@2;\n' |
| 420 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 444 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 421 { 'base': self.svn_base + 'trunk' }) | 445 { 'base': self.svn_base + 'trunk' }) |
| 422 self.check((out, '', 0), results) | 446 self.check((out, '', 0), results) |
| 423 | 447 |
| 424 | 448 |
| 425 class GClientSmokeGIT(GClientSmokeBase): | 449 class GClientSmokeGIT(GClientSmokeBase): |
| 426 def testSync(self): | 450 def testSync(self): |
| 427 # TODO(maruel): safesync, multiple solutions, invalid@revisions, | 451 # TODO(maruel): safesync. |
| 428 # multiple revisions. | |
| 429 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 452 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 430 # Test unversioned checkout. | 453 # Test unversioned checkout. |
| 431 results = self.gclient(['sync', '--deps', 'mac']) | 454 results = self.gclient(['sync', '--deps', 'mac']) |
| 432 out = results[0].splitlines(False) | 455 out = results[0].splitlines(False) |
| 433 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 456 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 434 # add sync parsing to get the list of updated files. | 457 # add sync parsing to get the list of updated files. |
| 435 self.assertEquals(13, len(out)) | 458 self.assertEquals(13, len(out)) |
| 436 self.assertTrue(results[1].startswith('Switched to a new branch \'')) | 459 self.assertTrue(results[1].startswith('Switched to a new branch \'')) |
| 437 self.assertEquals(0, results[2]) | 460 self.assertEquals(0, results[2]) |
| 438 tree = mangle_git_tree( | 461 tree = mangle_git_tree( |
| 439 ('src', FAKE.git_hashes['repo_1'][1][1]), | 462 ('src', FAKE.git_hashes['repo_1'][1][1]), |
| 440 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][0][1]), | 463 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][0][1]), |
| 441 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), | 464 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), |
| 442 ) | 465 ) |
| 443 tree[join('src', 'hooked1')] = 'hooked1' | 466 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
| 444 tree[join('src', 'hooked2')] = 'hooked2' | 467 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 445 self.assertTree(tree) | 468 self.assertTree(tree) |
| 446 | 469 |
| 447 # Manually remove hooked1 before synching to make sure it's not recreated. | 470 # Manually remove git_hooked1 before synching to make sure it's not |
| 448 os.remove(join(self.root_dir, 'src', 'hooked1')) | 471 # recreated. |
| 472 os.remove(join(self.root_dir, 'src', 'git_hooked1')) |
| 449 | 473 |
| 450 # Test incremental versioned sync: sync backward. | 474 # Test incremental versioned sync: sync backward. |
| 451 results = self.gclient(['sync', '--revision', | 475 results = self.gclient(['sync', '--revision', |
| 452 'src@' + FAKE.git_hashes['repo_1'][0][0], | 476 'src@' + FAKE.git_hashes['repo_1'][0][0], |
| 453 '--deps', 'mac', '--delete_unversioned_trees']) | 477 '--deps', 'mac', '--delete_unversioned_trees']) |
| 454 logging.debug(results[0]) | 478 logging.debug(results[0]) |
| 455 out = results[0].splitlines(False) | 479 out = results[0].splitlines(False) |
| 456 self.assertEquals(20, len(out)) | 480 self.assertEquals(20, len(out)) |
| 457 self.checkString('', results[1]) | 481 self.checkString('', results[1]) |
| 458 self.assertEquals(0, results[2]) | 482 self.assertEquals(0, results[2]) |
| 459 tree = mangle_git_tree( | 483 tree = mangle_git_tree( |
| 460 ('src', FAKE.git_hashes['repo_1'][0][1]), | 484 ('src', FAKE.git_hashes['repo_1'][0][1]), |
| 461 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][1][1]), | 485 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][1][1]), |
| 462 (join('src', 'repo2', 'repo3'), FAKE.git_hashes['repo_3'][1][1]), | 486 (join('src', 'repo2', 'repo3'), FAKE.git_hashes['repo_3'][1][1]), |
| 463 (join('src', 'repo4'), FAKE.git_hashes['repo_4'][1][1]), | 487 (join('src', 'repo4'), FAKE.git_hashes['repo_4'][1][1]), |
| 464 ) | 488 ) |
| 465 tree[join('src', 'hooked2')] = 'hooked2' | 489 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 466 self.assertTree(tree) | 490 self.assertTree(tree) |
| 467 # Test incremental sync: delete-unversioned_trees isn't there. | 491 # Test incremental sync: delete-unversioned_trees isn't there. |
| 468 results = self.gclient(['sync', '--deps', 'mac']) | 492 results = self.gclient(['sync', '--deps', 'mac']) |
| 469 logging.debug(results[0]) | 493 logging.debug(results[0]) |
| 470 out = results[0].splitlines(False) | 494 out = results[0].splitlines(False) |
| 471 self.assertEquals(25, len(out)) | 495 self.assertEquals(25, len(out)) |
| 472 self.checkString('', results[1]) | 496 self.checkString('', results[1]) |
| 473 self.assertEquals(0, results[2]) | 497 self.assertEquals(0, results[2]) |
| 474 tree = mangle_git_tree( | 498 tree = mangle_git_tree( |
| 475 ('src', FAKE.git_hashes['repo_1'][1][1]), | 499 ('src', FAKE.git_hashes['repo_1'][1][1]), |
| 476 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][1][1]), | 500 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][1][1]), |
| 477 (join('src', 'repo2', 'repo3'), FAKE.git_hashes['repo_3'][1][1]), | 501 (join('src', 'repo2', 'repo3'), FAKE.git_hashes['repo_3'][1][1]), |
| 478 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), | 502 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), |
| 479 (join('src', 'repo4'), FAKE.git_hashes['repo_4'][1][1]), | 503 (join('src', 'repo4'), FAKE.git_hashes['repo_4'][1][1]), |
| 480 ) | 504 ) |
| 481 tree[join('src', 'hooked1')] = 'hooked1' | 505 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
| 482 tree[join('src', 'hooked2')] = 'hooked2' | 506 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 483 self.assertTree(tree) | 507 self.assertTree(tree) |
| 484 | 508 |
| 485 def testRevertAndStatus(self): | 509 def testRevertAndStatus(self): |
| 486 """TODO(maruel): Remove this line once this test is fixed.""" | 510 """TODO(maruel): Remove this line once this test is fixed.""" |
| 487 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 511 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 488 # Tested in testSync. | 512 # Tested in testSync. |
| 489 self.gclient(['sync', '--deps', 'mac']) | 513 self.gclient(['sync', '--deps', 'mac']) |
| 490 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') | 514 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') |
| 491 | 515 |
| 492 results = self.gclient(['status']) | 516 results = self.gclient(['status']) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 503 self.assertEquals(7, len(out)) | 527 self.assertEquals(7, len(out)) |
| 504 self.checkString('', results[1]) | 528 self.checkString('', results[1]) |
| 505 self.assertEquals(0, results[2]) | 529 self.assertEquals(0, results[2]) |
| 506 tree = mangle_git_tree( | 530 tree = mangle_git_tree( |
| 507 ('src', FAKE.git_hashes['repo_1'][1][1]), | 531 ('src', FAKE.git_hashes['repo_1'][1][1]), |
| 508 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][0][1]), | 532 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][0][1]), |
| 509 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), | 533 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), |
| 510 ) | 534 ) |
| 511 # TODO(maruel): http://crosbug.com/3583 This file should have been removed. | 535 # TODO(maruel): http://crosbug.com/3583 This file should have been removed. |
| 512 tree[join('src', 'repo2', 'hi')] = 'Hey!' | 536 tree[join('src', 'repo2', 'hi')] = 'Hey!' |
| 513 tree[join('src', 'hooked1')] = 'hooked1' | 537 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
| 514 tree[join('src', 'hooked2')] = 'hooked2' | 538 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 515 self.assertTree(tree) | 539 self.assertTree(tree) |
| 516 | 540 |
| 517 results = self.gclient(['status']) | 541 results = self.gclient(['status']) |
| 518 out = results[0].splitlines(False) | 542 out = results[0].splitlines(False) |
| 519 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 543 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 520 # files. | 544 # files. |
| 521 self.assertEquals(0, len(out)) | 545 self.assertEquals(0, len(out)) |
| 522 | 546 |
| 523 def testRunHooks(self): | 547 def testRunHooks(self): |
| 524 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 548 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 525 self.gclient(['sync', '--deps', 'mac']) | 549 self.gclient(['sync', '--deps', 'mac']) |
| 526 results = self.gclient(['runhooks']) | 550 results = self.gclient(['runhooks']) |
| 527 logging.debug(results[0]) | 551 logging.debug(results[0]) |
| 528 out = results[0].splitlines(False) | 552 out = results[0].splitlines(False) |
| 529 self.assertEquals(4, len(out)) | 553 self.assertEquals(4, len(out)) |
| 530 self.assertEquals(out[0], '') | 554 self.assertEquals(out[0], '') |
| 531 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 555 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 532 r'open\(\'src/hooked1\', \'w\'\)\.write\(\'hooked1\'\)\' in \'.*', | 556 r'open\(\'src/git_hooked1\', \'w\'\)\.write\(\'git_hooked1\'\)\' in \'.*', |
| 533 out[1])) | 557 out[1])) |
| 534 self.assertEquals(out[2], '') | 558 self.assertEquals(out[2], '') |
| 535 # runhooks runs all hooks even if not matching by design. | 559 # runhooks runs all hooks even if not matching by design. |
| 536 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 560 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 537 r'open\(\'src/hooked2\', \'w\'\)\.write\(\'hooked2\'\)\' in \'.*', | 561 r'open\(\'src/git_hooked2\', \'w\'\)\.write\(\'git_hooked2\'\)\' in \'.*', |
| 538 out[3])) | 562 out[3])) |
| 539 self.checkString('', results[1]) | 563 self.checkString('', results[1]) |
| 540 self.assertEquals(0, results[2]) | 564 self.assertEquals(0, results[2]) |
| 541 | 565 |
| 542 def testRevInfo(self): | 566 def testRevInfo(self): |
| 543 # TODO(maruel): Test multiple solutions. | 567 # TODO(maruel): Test multiple solutions. |
| 544 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 568 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 545 self.gclient(['sync', '--deps', 'mac']) | 569 self.gclient(['sync', '--deps', 'mac']) |
| 546 results = self.gclient(['revinfo']) | 570 results = self.gclient(['revinfo']) |
| 547 out = ('src: %(base)srepo_1@%(hash1)s;\n' | 571 out = ('src: %(base)srepo_1@%(hash1)s;\n' |
| 548 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 572 'src/repo2: %(base)srepo_2@%(hash2)s;\n' |
| 549 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 573 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
| 550 { | 574 { |
| 551 'base': self.git_base, | 575 'base': self.git_base, |
| 552 'hash1': FAKE.git_hashes['repo_1'][1][0], | 576 'hash1': FAKE.git_hashes['repo_1'][1][0], |
| 553 'hash2': FAKE.git_hashes['repo_2'][0][0], | 577 'hash2': FAKE.git_hashes['repo_2'][0][0], |
| 554 'hash3': FAKE.git_hashes['repo_3'][1][0], | 578 'hash3': FAKE.git_hashes['repo_3'][1][0], |
| 555 }) | 579 }) |
| 556 self.check((out, '', 0), results) | 580 self.check((out, '', 0), results) |
| 557 | 581 |
| 558 | 582 |
| 583 class GClientSmokeBoth(GClientSmokeBase): |
| 584 def testMultiSolutions(self): |
| 585 self.gclient(['config', '--spec', |
| 586 'solutions=[' |
| 587 '{"name": "src",' |
| 588 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 589 '{"name": "src-git",' |
| 590 '"url": "' + self.git_base + 'repo_1"}]']) |
| 591 results = self.gclient(['sync', '--deps', 'mac']) |
| 592 out = results[0].splitlines(False) |
| 593 self.assertEquals(32, len(out)) |
| 594 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 595 # new branch \'hash\''. |
| 596 #self.checkString('', results[1]) |
| 597 self.assertEquals(0, results[2]) |
| 598 tree = mangle_git_tree( |
| 599 ('src-git', FAKE.git_hashes['repo_1'][1][1]), |
| 600 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][0][1]), |
| 601 (join('src', 'repo2', 'repo_renamed'), FAKE.git_hashes['repo_3'][1][1]), |
| 602 ) |
| 603 tree.update(mangle_svn_tree( |
| 604 (join('trunk', 'src'), 'src', FAKE.svn_revs[2]), |
| 605 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), |
| 606 FAKE.svn_revs[1]), |
| 607 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 608 )) |
| 609 tree[join('src', 'git_hooked1')] = 'git_hooked1' |
| 610 tree[join('src', 'git_hooked2')] = 'git_hooked2' |
| 611 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' |
| 612 tree[join('src', 'svn_hooked2')] = 'svn_hooked2' |
| 613 self.assertTree(tree) |
| 614 |
| 615 def testMultiSolutionsMultiRev(self): |
| 616 self.gclient(['config', '--spec', |
| 617 'solutions=[' |
| 618 '{"name": "src",' |
| 619 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 620 '{"name": "src-git",' |
| 621 '"url": "' + self.git_base + 'repo_1"}]']) |
| 622 results = self.gclient(['sync', '--deps', 'mac', '--revision', '1', '-r', |
| 623 'src-git@' + FAKE.git_hashes['repo_1'][0][0]]) |
| 624 out = results[0].splitlines(False) |
| 625 self.assertEquals(35, len(out)) |
| 626 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 627 # new branch \'hash\''. |
| 628 #self.checkString('', results[1]) |
| 629 self.assertEquals(0, results[2]) |
| 630 tree = mangle_git_tree( |
| 631 ('src-git', FAKE.git_hashes['repo_1'][0][1]), |
| 632 (join('src', 'repo2'), FAKE.git_hashes['repo_2'][1][1]), |
| 633 (join('src', 'repo2', 'repo3'), FAKE.git_hashes['repo_3'][1][1]), |
| 634 (join('src', 'repo4'), FAKE.git_hashes['repo_4'][1][1]), |
| 635 ) |
| 636 tree.update(mangle_svn_tree( |
| 637 (join('trunk', 'src'), 'src', FAKE.svn_revs[1]), |
| 638 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), |
| 639 FAKE.svn_revs[2]), |
| 640 (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), |
| 641 (join('trunk', 'third_party', 'foo'), |
| 642 join('src', 'third_party', 'prout'), |
| 643 FAKE.svn_revs[2]), |
| 644 )) |
| 645 self.assertTree(tree) |
| 646 |
| 647 |
| 559 if __name__ == '__main__': | 648 if __name__ == '__main__': |
| 560 if '-v' in sys.argv: | 649 if '-v' in sys.argv: |
| 561 logging.basicConfig(level=logging.DEBUG) | 650 logging.basicConfig(level=logging.DEBUG) |
| 562 if '-l' in sys.argv: | 651 if '-l' in sys.argv: |
| 563 SHOULD_LEAK = True | 652 SHOULD_LEAK = True |
| 564 sys.argv.remove('-l') | 653 sys.argv.remove('-l') |
| 565 FAKE = FakeRepos(TRIAL_DIR, SHOULD_LEAK, True) | 654 FAKE = FakeRepos(TRIAL_DIR, SHOULD_LEAK, True) |
| 566 try: | 655 try: |
| 567 FAKE.setUp() | 656 FAKE.setUp() |
| 568 unittest.main() | 657 unittest.main() |
| 569 finally: | 658 finally: |
| 570 FAKE.tearDown() | 659 FAKE.tearDown() |
| OLD | NEW |