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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 upload_args, | 653 upload_args, |
654 description, | 654 description, |
655 reviewers, | 655 reviewers, |
656 squash=False, | 656 squash=False, |
657 expected_upstream_ref='origin/refs/heads/master'): | 657 expected_upstream_ref='origin/refs/heads/master'): |
658 """Generic gerrit upload test framework.""" | 658 """Generic gerrit upload test framework.""" |
659 self.calls = self._gerrit_base_calls() | 659 self.calls = self._gerrit_base_calls() |
660 self.calls += self._gerrit_upload_calls( | 660 self.calls += self._gerrit_upload_calls( |
661 description, reviewers, squash, | 661 description, reviewers, squash, |
662 expected_upstream_ref=expected_upstream_ref) | 662 expected_upstream_ref=expected_upstream_ref) |
| 663 # Uncomment when debugging. |
| 664 # print '\n'.join(map(lambda x: '%2i: %s' % x, enumerate(self.calls))) |
663 git_cl.main(['upload'] + upload_args) | 665 git_cl.main(['upload'] + upload_args) |
664 | 666 |
665 def test_gerrit_upload_without_change_id(self): | 667 def test_gerrit_upload_without_change_id(self): |
666 self._run_gerrit_upload_test( | 668 self._run_gerrit_upload_test( |
667 [], | 669 [], |
668 'desc\n\nBUG=\n', | 670 'desc\n\nBUG=\n', |
669 []) | 671 []) |
670 | 672 |
671 def test_gerrit_no_reviewer(self): | 673 def test_gerrit_no_reviewer(self): |
672 self._run_gerrit_upload_test( | 674 self._run_gerrit_upload_test( |
673 [], | 675 [], |
674 'desc\n\nBUG=\nChange-Id:123456789\n', | 676 'desc\n\nBUG=\n\nChange-Id: I123456789\n', |
675 []) | 677 []) |
676 | 678 |
677 def test_gerrit_reviewers_cmd_line(self): | 679 def test_gerrit_reviewers_cmd_line(self): |
678 self._run_gerrit_upload_test( | 680 self._run_gerrit_upload_test( |
679 ['-r', 'foo@example.com'], | 681 ['-r', 'foo@example.com'], |
680 'desc\n\nBUG=\nChange-Id:123456789', | 682 'desc\n\nBUG=\n\nChange-Id: I123456789', |
681 ['foo@example.com']) | 683 ['foo@example.com']) |
682 | 684 |
683 def test_gerrit_reviewer_multiple(self): | 685 def test_gerrit_reviewer_multiple(self): |
684 self._run_gerrit_upload_test( | 686 self._run_gerrit_upload_test( |
685 [], | 687 [], |
686 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n' | 688 'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n\n' |
687 'Change-Id:123456789\n', | 689 'Change-Id: 123456789\n', |
688 ['reviewer@example.com', 'another@example.com']) | 690 ['reviewer@example.com', 'another@example.com']) |
689 | 691 |
690 def test_gerrit_upload_squash(self): | 692 def test_gerrit_upload_squash(self): |
691 self._run_gerrit_upload_test( | 693 self._run_gerrit_upload_test( |
692 ['--squash'], | 694 ['--squash'], |
693 'desc\n\nBUG=\nChange-Id:123456789\n', | 695 'desc\n\nBUG=\nChange-Id:123456789\n', |
694 [], | 696 [], |
695 squash=True, | 697 squash=True, |
696 expected_upstream_ref='origin/master') | 698 expected_upstream_ref='origin/master') |
697 | 699 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 self.calls += [ | 972 self.calls += [ |
971 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 973 ((['git', 'apply', '--index', '-p0', '--3way'],), '', |
972 subprocess2.CalledProcessError(1, '', '', '', '')), | 974 subprocess2.CalledProcessError(1, '', '', '', '')), |
973 ] | 975 ] |
974 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 976 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
975 | 977 |
976 if __name__ == '__main__': | 978 if __name__ == '__main__': |
977 git_cl.logging.basicConfig( | 979 git_cl.logging.basicConfig( |
978 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 980 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
979 unittest.main() | 981 unittest.main() |
OLD | NEW |