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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 ((['git', | 214 ((['git', |
215 'config', 'branch.master.rietveldissue', '1'],), ''), | 215 'config', 'branch.master.rietveldissue', '1'],), ''), |
216 ((['git', 'config', 'branch.master.rietveldserver', | 216 ((['git', 'config', 'branch.master.rietveldserver', |
217 'https://codereview.example.com'],), ''), | 217 'https://codereview.example.com'],), ''), |
218 ((['git', | 218 ((['git', |
219 'config', 'branch.master.rietveldpatchset', '2'],), ''), | 219 'config', 'branch.master.rietveldpatchset', '2'],), ''), |
220 ((['git', 'rev-parse', 'HEAD'],), 'hash'), | 220 ((['git', 'rev-parse', 'HEAD'],), 'hash'), |
221 ((['git', 'symbolic-ref', 'HEAD'],), 'hash'), | 221 ((['git', 'symbolic-ref', 'HEAD'],), 'hash'), |
222 ((['git', | 222 ((['git', |
223 'config', 'branch.hash.last-upload-hash', 'hash'],), ''), | 223 'config', 'branch.hash.last-upload-hash', 'hash'],), ''), |
| 224 ((['git', 'config', 'rietveld.run-post-upload-hook'],), ''), |
224 ] | 225 ] |
225 | 226 |
226 @staticmethod | 227 @staticmethod |
227 def _git_sanity_checks(diff_base, working_branch): | 228 def _git_sanity_checks(diff_base, working_branch): |
228 fake_ancestor = 'fake_ancestor' | 229 fake_ancestor = 'fake_ancestor' |
229 fake_cl = 'fake_cl_for_patch' | 230 fake_cl = 'fake_cl_for_patch' |
230 return [ | 231 return [ |
231 # Calls to verify branch point is ancestor | 232 # Calls to verify branch point is ancestor |
232 ((['git', | 233 ((['git', |
233 'rev-parse', '--verify', diff_base],), fake_ancestor), | 234 'rev-parse', '--verify', diff_base],), fake_ancestor), |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 ((['git', 'config', '--unset-all', | 725 ((['git', 'config', '--unset-all', |
725 'rietveld.cpplint-regex'],), ''), | 726 'rietveld.cpplint-regex'],), ''), |
726 ((['git', 'config', '--unset-all', | 727 ((['git', 'config', '--unset-all', |
727 'rietveld.force-https-commit-url'],), ''), | 728 'rietveld.force-https-commit-url'],), ''), |
728 ((['git', 'config', '--unset-all', | 729 ((['git', 'config', '--unset-all', |
729 'rietveld.cpplint-ignore-regex'],), ''), | 730 'rietveld.cpplint-ignore-regex'],), ''), |
730 ((['git', 'config', '--unset-all', | 731 ((['git', 'config', '--unset-all', |
731 'rietveld.project'],), ''), | 732 'rietveld.project'],), ''), |
732 ((['git', 'config', '--unset-all', | 733 ((['git', 'config', '--unset-all', |
733 'rietveld.pending-ref-prefix'],), ''), | 734 'rietveld.pending-ref-prefix'],), ''), |
| 735 ((['git', 'config', '--unset-all', |
| 736 'rietveld.run-post-upload-hook'],), ''), |
734 ((['git', 'config', 'gerrit.host', | 737 ((['git', 'config', 'gerrit.host', |
735 'gerrit.chromium.org'],), ''), | 738 'gerrit.chromium.org'],), ''), |
736 # DownloadHooks(False) | 739 # DownloadHooks(False) |
737 ((['git', 'config', 'gerrit.host'],), | 740 ((['git', 'config', 'gerrit.host'],), |
738 'gerrit.chromium.org'), | 741 'gerrit.chromium.org'), |
739 ((['git', 'rev-parse', '--show-cdup'],), ''), | 742 ((['git', 'rev-parse', '--show-cdup'],), ''), |
740 ((commit_msg_path, os.X_OK,), False), | 743 ((commit_msg_path, os.X_OK,), False), |
741 (('https://gerrit-review.googlesource.com/tools/hooks/commit-msg', | 744 (('https://gerrit-review.googlesource.com/tools/hooks/commit-msg', |
742 commit_msg_path,), ''), | 745 commit_msg_path,), ''), |
743 ((commit_msg_path,), True), | 746 ((commit_msg_path,), True), |
744 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), | 747 ((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''), |
745 # GetCodereviewSettingsInteractively | 748 # GetCodereviewSettingsInteractively |
746 ((['git', 'config', 'rietveld.server'],), | 749 ((['git', 'config', 'rietveld.server'],), |
747 'gerrit.chromium.org'), | 750 'gerrit.chromium.org'), |
748 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), | 751 (('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',), |
749 ''), | 752 ''), |
750 ((['git', 'config', 'rietveld.cc'],), ''), | 753 ((['git', 'config', 'rietveld.cc'],), ''), |
751 (('CC list:',), ''), | 754 (('CC list:',), ''), |
752 ((['git', 'config', 'rietveld.private'],), ''), | 755 ((['git', 'config', 'rietveld.private'],), ''), |
753 (('Private flag (rietveld only):',), ''), | 756 (('Private flag (rietveld only):',), ''), |
754 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 757 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
755 (('Tree status URL:',), ''), | 758 (('Tree status URL:',), ''), |
756 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 759 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
757 (('ViewVC URL:',), ''), | 760 (('ViewVC URL:',), ''), |
758 # DownloadHooks(True) | 761 # DownloadHooks(True) |
759 ((['git', 'config', 'rietveld.bug-prefix'],), ''), | 762 ((['git', 'config', 'rietveld.bug-prefix'],), ''), |
760 (('Bug Prefix:',), ''), | 763 (('Bug Prefix:',), ''), |
| 764 ((['git', 'config', 'rietveld.run-post-upload-hook'],), ''), |
| 765 (('Run Post Upload Hook:',), ''), |
761 ((commit_msg_path, os.X_OK,), True), | 766 ((commit_msg_path, os.X_OK,), True), |
762 ] | 767 ] |
763 git_cl.main(['config']) | 768 git_cl.main(['config']) |
764 | 769 |
765 def test_update_reviewers(self): | 770 def test_update_reviewers(self): |
766 data = [ | 771 data = [ |
767 ('foo', [], 'foo'), | 772 ('foo', [], 'foo'), |
768 ('foo\nR=xx', [], 'foo\nR=xx'), | 773 ('foo\nR=xx', [], 'foo\nR=xx'), |
769 ('foo\nTBR=xx', [], 'foo\nTBR=xx'), | 774 ('foo\nTBR=xx', [], 'foo\nTBR=xx'), |
770 ('foo', ['a@c'], 'foo\n\nR=a@c'), | 775 ('foo', ['a@c'], 'foo\n\nR=a@c'), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 # Check target refs for pending prefix. | 845 # Check target refs for pending prefix. |
841 self.assertEqual('prefix/heads/master', | 846 self.assertEqual('prefix/heads/master', |
842 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', | 847 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', |
843 None, 'prefix/')) | 848 None, 'prefix/')) |
844 | 849 |
845 | 850 |
846 if __name__ == '__main__': | 851 if __name__ == '__main__': |
847 git_cl.logging.basicConfig( | 852 git_cl.logging.basicConfig( |
848 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 853 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
849 unittest.main() | 854 unittest.main() |
OLD | NEW |