| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import StringIO | 9 import StringIO |
| 10 import stat | 10 import stat |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 @classmethod | 314 @classmethod |
| 315 def _dcommit_calls_normal(cls): | 315 def _dcommit_calls_normal(cls): |
| 316 return [ | 316 return [ |
| 317 ((['git', 'rev-parse', '--show-cdup'],), ''), | 317 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 318 ((['git', 'rev-parse', 'HEAD'],), | 318 ((['git', 'rev-parse', 'HEAD'],), |
| 319 '00ff397798ea57439712ed7e04ab96e13969ef40'), | 319 '00ff397798ea57439712ed7e04ab96e13969ef40'), |
| 320 ((['git', | 320 ((['git', |
| 321 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', | 321 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', |
| 322 '.'],), | 322 '.'],), |
| 323 'M\tPRESUBMIT.py'), | 323 'M\tPRESUBMIT.py'), |
| 324 ((['git', 'config', 'gerrit.host'],), ''), | |
| 325 ((['git', | 324 ((['git', |
| 326 'config', 'branch.working.rietveldissue'],), '12345'), | 325 'config', 'branch.working.rietveldissue'],), '12345'), |
| 327 ((['git', | 326 ((['git', |
| 328 'config', 'branch.working.rietveldpatchset'],), '31137'), | 327 'config', 'branch.working.rietveldpatchset'],), '31137'), |
| 329 ((['git', 'config', 'branch.working.rietveldserver'],), | 328 ((['git', 'config', 'branch.working.rietveldserver'],), |
| 330 'codereview.example.com'), | 329 'codereview.example.com'), |
| 331 ((['git', 'config', 'user.email'],), 'author@example.com'), | 330 ((['git', 'config', 'user.email'],), 'author@example.com'), |
| 332 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 331 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
| 333 ] | 332 ] |
| 334 | 333 |
| 335 @classmethod | 334 @classmethod |
| 336 def _dcommit_calls_bypassed(cls): | 335 def _dcommit_calls_bypassed(cls): |
| 337 return [ | 336 return [ |
| 338 ((['git', 'config', 'gerrit.host'],), ''), | |
| 339 ((['git', | 337 ((['git', |
| 340 'config', 'branch.working.rietveldissue'],), '12345'), | 338 'config', 'branch.working.rietveldissue'],), '12345'), |
| 341 ((['git', 'config', 'branch.working.rietveldserver'],), | 339 ((['git', 'config', 'branch.working.rietveldserver'],), |
| 342 'codereview.example.com'), | 340 'codereview.example.com'), |
| 343 ] | 341 ] |
| 344 | 342 |
| 345 @classmethod | 343 @classmethod |
| 346 def _dcommit_calls_3(cls): | 344 def _dcommit_calls_3(cls): |
| 347 return [ | 345 return [ |
| 346 ((['git', 'config', 'gerrit.host'],), ''), |
| 348 ((['git', | 347 ((['git', |
| 349 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 348 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 350 '-l100000', '-C50', 'fake_ancestor_sha', | 349 '-l100000', '-C50', 'fake_ancestor_sha', |
| 351 'refs/heads/working'],), | 350 'refs/heads/working'],), |
| 352 (' PRESUBMIT.py | 2 +-\n' | 351 (' PRESUBMIT.py | 2 +-\n' |
| 353 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), | 352 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), |
| 354 ((['git', 'show-ref', '--quiet', '--verify', | 353 ((['git', 'show-ref', '--quiet', '--verify', |
| 355 'refs/heads/git-cl-commit'],), | 354 'refs/heads/git-cl-commit'],), |
| 356 (('', None), 0)), | 355 (('', None), 0)), |
| 357 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 356 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 ((['get_or_create_merge_base', 'master', 'master'],), | 562 ((['get_or_create_merge_base', 'master', 'master'],), |
| 564 'fake_ancestor_sha'), | 563 'fake_ancestor_sha'), |
| 565 ((['git', 'config', 'gerrit.host'],), 'True'), | 564 ((['git', 'config', 'gerrit.host'],), 'True'), |
| 566 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ | 565 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ |
| 567 ((['git', 'rev-parse', '--show-cdup'],), ''), | 566 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 568 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 567 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 569 ((['git', | 568 ((['git', |
| 570 'diff', '--name-status', '--no-renames', '-r', | 569 'diff', '--name-status', '--no-renames', '-r', |
| 571 'fake_ancestor_sha...', '.'],), | 570 'fake_ancestor_sha...', '.'],), |
| 572 'M\t.gitignore\n'), | 571 'M\t.gitignore\n'), |
| 573 ((['git', 'config', 'branch.master.gerritissue'],), ''), | 572 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 574 ((['git', | 573 ((['git', |
| 575 'config', 'branch.master.rietveldpatchset'],), ''), | 574 'config', 'branch.master.rietveldpatchset'],), ''), |
| 576 ((['git', | 575 ((['git', |
| 577 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), | 576 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), |
| 578 'foo'), | 577 'foo'), |
| 579 ((['git', 'config', 'user.email'],), 'me@example.com'), | 578 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 580 ((['git', | 579 ((['git', |
| 581 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 580 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 582 '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],), | 581 '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],), |
| 583 '+dat'), | 582 '+dat'), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 'remote: Processing changes: new: 1, done\n' | 655 'remote: Processing changes: new: 1, done\n' |
| 657 'remote:\n' | 656 'remote:\n' |
| 658 'remote: New Changes:\n' | 657 'remote: New Changes:\n' |
| 659 'remote: https://chromium-review.googlesource.com/123456 XXX.\n' | 658 'remote: https://chromium-review.googlesource.com/123456 XXX.\n' |
| 660 'remote:\n' | 659 'remote:\n' |
| 661 'To https://chromium.googlesource.com/yyy/zzz\n' | 660 'To https://chromium.googlesource.com/yyy/zzz\n' |
| 662 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')), | 661 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')), |
| 663 ] | 662 ] |
| 664 if squash: | 663 if squash: |
| 665 calls += [ | 664 calls += [ |
| 666 ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), | 665 ((['git', 'config', 'branch.master.rietveldissue', '123456'],), ''), |
| 667 ((['git', 'rev-parse', 'HEAD'],), 'abcdef0123456789'), | 666 ((['git', 'rev-parse', 'HEAD'],), 'abcdef0123456789'), |
| 668 ((['git', 'update-ref', '-m', 'Uploaded abcdef0123456789', | 667 ((['git', 'update-ref', '-m', 'Uploaded abcdef0123456789', |
| 669 'refs/heads/git_cl_uploads/master', 'abcdef0123456789'],), | 668 'refs/heads/git_cl_uploads/master', 'abcdef0123456789'],), |
| 670 '') | 669 '') |
| 671 ] | 670 ] |
| 672 calls += cls._git_post_upload_calls() | 671 calls += cls._git_post_upload_calls() |
| 673 return calls | 672 return calls |
| 674 | 673 |
| 675 def _run_gerrit_upload_test( | 674 def _run_gerrit_upload_test( |
| 676 self, | 675 self, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 self.calls += [ | 916 self.calls += [ |
| 918 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 917 ((['git', 'apply', '--index', '-p0', '--3way'],), '', |
| 919 subprocess2.CalledProcessError(1, '', '', '', '')), | 918 subprocess2.CalledProcessError(1, '', '', '', '')), |
| 920 ] | 919 ] |
| 921 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 920 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
| 922 | 921 |
| 923 if __name__ == '__main__': | 922 if __name__ == '__main__': |
| 924 git_cl.logging.basicConfig( | 923 git_cl.logging.basicConfig( |
| 925 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 924 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 926 unittest.main() | 925 unittest.main() |
| OLD | NEW |