| 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 |
| 11 import sys | 11 import sys |
| 12 import unittest | 12 import unittest |
| 13 | 13 |
| 14 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 14 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 15 | 15 |
| 16 from testing_support.auto_stub import TestCase | 16 from testing_support.auto_stub import TestCase |
| 17 | 17 |
| 18 import git_cl | 18 import git_cl |
| 19 import git_common | 19 import git_common |
| 20 import git_footers |
| 20 import subprocess2 | 21 import subprocess2 |
| 21 | 22 |
| 22 class PresubmitMock(object): | 23 class PresubmitMock(object): |
| 23 def __init__(self, *args, **kwargs): | 24 def __init__(self, *args, **kwargs): |
| 24 self.reviewers = [] | 25 self.reviewers = [] |
| 25 @staticmethod | 26 @staticmethod |
| 26 def should_continue(): | 27 def should_continue(): |
| 27 return True | 28 return True |
| 28 | 29 |
| 29 | 30 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 582 |
| 582 @classmethod | 583 @classmethod |
| 583 def _gerrit_upload_calls(cls, description, reviewers, squash, | 584 def _gerrit_upload_calls(cls, description, reviewers, squash, |
| 584 expected_upstream_ref='origin/refs/heads/master'): | 585 expected_upstream_ref='origin/refs/heads/master'): |
| 585 calls = [ | 586 calls = [ |
| 586 ((['git', 'config', '--bool', 'gerrit.squash-uploads'],), 'false'), | 587 ((['git', 'config', '--bool', 'gerrit.squash-uploads'],), 'false'), |
| 587 ((['git', 'log', '--pretty=format:%s\n\n%b', | 588 ((['git', 'log', '--pretty=format:%s\n\n%b', |
| 588 'fake_ancestor_sha..HEAD'],), | 589 'fake_ancestor_sha..HEAD'],), |
| 589 description) | 590 description) |
| 590 ] | 591 ] |
| 591 if git_cl.CHANGE_ID not in description: | 592 if not git_footers.get_footer_change_id(description) and not squash: |
| 592 calls += [ | 593 calls += [ |
| 593 ((['git', 'log', '--pretty=format:%s\n\n%b', | 594 ((['git', 'log', '--pretty=format:%s\n\n%b', |
| 594 'fake_ancestor_sha..HEAD'],), | 595 'fake_ancestor_sha..HEAD'],), |
| 595 description), | 596 description), |
| 596 ((['git', 'commit', '--amend', '-m', description],), | 597 ((['git', 'commit', '--amend', '-m', description],), |
| 597 ''), | 598 ''), |
| 598 ((['git', 'log', '--pretty=format:%s\n\n%b', | 599 ((['git', 'log', '--pretty=format:%s\n\n%b', |
| 599 'fake_ancestor_sha..HEAD'],), | 600 'fake_ancestor_sha..HEAD'],), |
| 600 description) | 601 description) |
| 601 ] | 602 ] |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 self.calls += [ | 973 self.calls += [ |
| 973 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 974 ((['git', 'apply', '--index', '-p0', '--3way'],), '', |
| 974 subprocess2.CalledProcessError(1, '', '', '', '')), | 975 subprocess2.CalledProcessError(1, '', '', '', '')), |
| 975 ] | 976 ] |
| 976 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 977 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
| 977 | 978 |
| 978 if __name__ == '__main__': | 979 if __name__ == '__main__': |
| 979 git_cl.logging.basicConfig( | 980 git_cl.logging.basicConfig( |
| 980 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 981 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 981 unittest.main() | 982 unittest.main() |
| OLD | NEW |