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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 post_amend_description='desc\n\nBUG=\n\nChange-Id: Ixxx') | 967 post_amend_description='desc\n\nBUG=\n\nChange-Id: Ixxx') |
968 | 968 |
969 def test_gerrit_no_reviewer(self): | 969 def test_gerrit_no_reviewer(self): |
970 self._run_gerrit_upload_test( | 970 self._run_gerrit_upload_test( |
971 [], | 971 [], |
972 'desc\n\nBUG=\n\nChange-Id: I123456789\n', | 972 'desc\n\nBUG=\n\nChange-Id: I123456789\n', |
973 [], | 973 [], |
974 squash=False, | 974 squash=False, |
975 squash_mode='override_nosquash') | 975 squash_mode='override_nosquash') |
976 | 976 |
977 def test_gerrit_patch_title(self): | 977 def test_gerrit_patch_bad_chars(self): |
| 978 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
978 self._run_gerrit_upload_test( | 979 self._run_gerrit_upload_test( |
979 ['-t', 'Don\'t put under_scores as they become spaces'], | 980 ['-f', '-t', 'Don\'t put bad cha,.rs'], |
980 'desc\n\nBUG=\n\nChange-Id: I123456789', | 981 'desc\n\nBUG=\n\nChange-Id: I123456789', |
981 squash=False, | 982 squash=False, |
982 squash_mode='override_nosquash', | 983 squash_mode='override_nosquash', |
983 ref_suffix='%m=Don\'t_put_under_scores_as_they_become_spaces') | 984 ref_suffix='%m=Dont_put_bad_chars') |
| 985 self.assertIn( |
| 986 'WARNING: Patchset title may only contain alphanumeric chars ' |
| 987 'and spaces. Cleaned up title:\nDont put bad chars\n', |
| 988 git_cl.sys.stdout.getvalue()) |
984 | 989 |
985 def test_gerrit_reviewers_cmd_line(self): | 990 def test_gerrit_reviewers_cmd_line(self): |
986 self._run_gerrit_upload_test( | 991 self._run_gerrit_upload_test( |
987 ['-r', 'foo@example.com', '--send-mail'], | 992 ['-r', 'foo@example.com', '--send-mail'], |
988 'desc\n\nBUG=\n\nChange-Id: I123456789', | 993 'desc\n\nBUG=\n\nChange-Id: I123456789', |
989 ['foo@example.com'], | 994 ['foo@example.com'], |
990 squash=False, | 995 squash=False, |
991 squash_mode='override_nosquash', | 996 squash_mode='override_nosquash', |
992 notify=True) | 997 notify=True) |
993 | 998 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1755 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
1751 ''), | 1756 ''), |
1752 ] | 1757 ] |
1753 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1758 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
1754 | 1759 |
1755 | 1760 |
1756 if __name__ == '__main__': | 1761 if __name__ == '__main__': |
1757 git_cl.logging.basicConfig( | 1762 git_cl.logging.basicConfig( |
1758 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1763 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1759 unittest.main() | 1764 unittest.main() |
OLD | NEW |