| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 for i, c in enumerate(self.calls[:N])) | 281 for i, c in enumerate(self.calls[:N])) |
| 282 extended_msg = ( | 282 extended_msg = ( |
| 283 'A few prior calls:\n %s\n\n' | 283 'A few prior calls:\n %s\n\n' |
| 284 'This (expected):\n @%d: %r\n' | 284 'This (expected):\n @%d: %r\n' |
| 285 'This (actual):\n @%d: %r\n\n' | 285 'This (actual):\n @%d: %r\n\n' |
| 286 'A few following expected calls:\n %s' % | 286 'A few following expected calls:\n %s' % |
| 287 (prior_calls, len(self._calls_done), expected_args, | 287 (prior_calls, len(self._calls_done), expected_args, |
| 288 len(self._calls_done), args, following_calls)) | 288 len(self._calls_done), args, following_calls)) |
| 289 git_cl.logging.error(extended_msg) | 289 git_cl.logging.error(extended_msg) |
| 290 | 290 |
| 291 self.fail('@%d Expected: %r Actual: %r' % ( | 291 self.fail('@%d\n' |
| 292 ' Expected: %r\n' |
| 293 ' Actual: %r' % ( |
| 292 len(self._calls_done), expected_args, args)) | 294 len(self._calls_done), expected_args, args)) |
| 293 | 295 |
| 294 self._calls_done.append(top) | 296 self._calls_done.append(top) |
| 295 return result | 297 return result |
| 296 | 298 |
| 297 @classmethod | 299 @classmethod |
| 298 def _is_gerrit_calls(cls, gerrit=False): | 300 def _is_gerrit_calls(cls, gerrit=False): |
| 299 return [((['git', 'config', 'rietveld.autoupdate'],), ''), | 301 return [((['git', 'config', 'rietveld.autoupdate'],), ''), |
| 300 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] | 302 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] |
| 301 | 303 |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 squash_mode='override_nosquash', | 998 squash_mode='override_nosquash', |
| 997 notify=True) | 999 notify=True) |
| 998 | 1000 |
| 999 def test_gerrit_reviewer_multiple(self): | 1001 def test_gerrit_reviewer_multiple(self): |
| 1000 self._run_gerrit_upload_test( | 1002 self._run_gerrit_upload_test( |
| 1001 [], | 1003 [], |
| 1002 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n\n' | 1004 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n\n' |
| 1003 'Change-Id: 123456789\n', | 1005 'Change-Id: 123456789\n', |
| 1004 ['reviewer@example.com', 'another@example.com'], | 1006 ['reviewer@example.com', 'another@example.com'], |
| 1005 squash=False, | 1007 squash=False, |
| 1006 squash_mode='override_nosquash') | 1008 squash_mode='override_nosquash', |
| 1009 ref_suffix='%l=Code-Review+1') |
| 1007 | 1010 |
| 1008 def test_gerrit_upload_squash_first_is_default(self): | 1011 def test_gerrit_upload_squash_first_is_default(self): |
| 1009 # Mock Gerrit CL description to indicate the first upload. | 1012 # Mock Gerrit CL description to indicate the first upload. |
| 1010 self.mock(git_cl.Changelist, 'GetDescription', | 1013 self.mock(git_cl.Changelist, 'GetDescription', |
| 1011 lambda *_: None) | 1014 lambda *_: None) |
| 1012 self._run_gerrit_upload_test( | 1015 self._run_gerrit_upload_test( |
| 1013 [], | 1016 [], |
| 1014 'desc\nBUG=\n\nChange-Id: 123456789', | 1017 'desc\nBUG=\n\nChange-Id: 123456789', |
| 1015 [], | 1018 [], |
| 1016 expected_upstream_ref='origin/master') | 1019 expected_upstream_ref='origin/master') |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1758 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
| 1756 ''), | 1759 ''), |
| 1757 ] | 1760 ] |
| 1758 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1761 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
| 1759 | 1762 |
| 1760 | 1763 |
| 1761 if __name__ == '__main__': | 1764 if __name__ == '__main__': |
| 1762 git_cl.logging.basicConfig( | 1765 git_cl.logging.basicConfig( |
| 1763 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1766 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 1764 unittest.main() | 1767 unittest.main() |
| OLD | NEW |