| 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 git_cl.main(['upload', '--send-mail']) | 666 git_cl.main(['upload', '--send-mail']) |
| 667 self.fail() | 667 self.fail() |
| 668 except SystemExit: | 668 except SystemExit: |
| 669 self.assertEqual( | 669 self.assertEqual( |
| 670 'Using 50% similarity for rename/copy detection. Override with ' | 670 'Using 50% similarity for rename/copy detection. Override with ' |
| 671 '--similarity.\n', | 671 '--similarity.\n', |
| 672 stdout.getvalue()) | 672 stdout.getvalue()) |
| 673 self.assertEqual( | 673 self.assertEqual( |
| 674 'Must specify reviewers to send email.\n', stderr.getvalue()) | 674 'Must specify reviewers to send email.\n', stderr.getvalue()) |
| 675 | 675 |
| 676 def test_dcommit(self): | |
| 677 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | |
| 678 self.calls = ( | |
| 679 self._dcommit_calls_1() + | |
| 680 self._git_sanity_checks('fake_ancestor_sha', 'working') + | |
| 681 self._dcommit_calls_normal() + | |
| 682 self._dcommit_calls_3()) | |
| 683 git_cl.main(['dcommit']) | |
| 684 | |
| 685 def test_dcommit_bypass_hooks(self): | |
| 686 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | |
| 687 self.calls = ( | |
| 688 self._dcommit_calls_1() + | |
| 689 self._dcommit_calls_bypassed() + | |
| 690 self._dcommit_calls_3()) | |
| 691 git_cl.main(['dcommit', '--bypass-hooks']) | |
| 692 | |
| 693 | |
| 694 @classmethod | 676 @classmethod |
| 695 def _gerrit_ensure_auth_calls(cls, issue=None, skip_auth_check=False): | 677 def _gerrit_ensure_auth_calls(cls, issue=None, skip_auth_check=False): |
| 696 cmd = ['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'] | 678 cmd = ['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'] |
| 697 if skip_auth_check: | 679 if skip_auth_check: |
| 698 return [((cmd, ), 'true')] | 680 return [((cmd, ), 'true')] |
| 699 | 681 |
| 700 calls = [((cmd, ), '', subprocess2.CalledProcessError(1, '', '', '', ''))] | 682 calls = [((cmd, ), '', subprocess2.CalledProcessError(1, '', '', '', ''))] |
| 701 if issue: | 683 if issue: |
| 702 calls.extend([ | 684 calls.extend([ |
| 703 ((['git', 'config', 'branch.master.gerritserver'],), ''), | 685 ((['git', 'config', 'branch.master.gerritserver'],), ''), |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1611 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
| 1630 ''), | 1612 ''), |
| 1631 ] | 1613 ] |
| 1632 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1614 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
| 1633 | 1615 |
| 1634 | 1616 |
| 1635 if __name__ == '__main__': | 1617 if __name__ == '__main__': |
| 1636 git_cl.logging.basicConfig( | 1618 git_cl.logging.basicConfig( |
| 1637 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1619 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 1638 unittest.main() | 1620 unittest.main() |
| OLD | NEW |