OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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_common.py""" | 6 """Unit tests for git_common.py""" |
7 | 7 |
8 import binascii | 8 import binascii |
9 import collections | 9 import collections |
10 import os | 10 import os |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 self.repo.git('rebase', '--continue') | 724 self.repo.git('rebase', '--continue') |
725 | 725 |
726 self.assertSchema(""" | 726 self.assertSchema(""" |
727 A B C D E F G H I J K L | 727 A B C D E F G H I J K L |
728 | 728 |
729 X Y Z | 729 X Y Z |
730 | 730 |
731 CAT DOG | 731 CAT DOG |
732 """) | 732 """) |
733 | 733 |
734 def testStatus(self): | |
735 def inner(): | |
736 dictified_status = lambda: { | |
737 k: dict(v._asdict()) # pylint: disable=W0212 | |
738 for k, v in self.repo.run(self.gc.status) | |
739 } | |
740 self.repo.git('mv', 'file', 'cat') | |
741 with open('COOL', 'w') as f: | |
742 f.write('Super cool file!') | |
743 self.assertDictEqual( | |
744 dictified_status(), | |
745 {'cat': {'lstat': 'R', 'rstat': ' ', 'src': 'file'}, | |
746 'COOL': {'lstat': '?', 'rstat': '?', 'src': 'COOL'}} | |
747 ) | |
748 | |
749 self.repo.run(inner) | |
750 | |
734 | 751 |
735 class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase): | 752 class GitFreezeThaw(git_test_utils.GitRepoReadWriteTestBase): |
736 @classmethod | 753 @classmethod |
737 def setUpClass(cls): | 754 def setUpClass(cls): |
738 super(GitFreezeThaw, cls).setUpClass() | 755 super(GitFreezeThaw, cls).setUpClass() |
739 import git_common | 756 import git_common |
740 cls.gc = git_common | 757 cls.gc = git_common |
741 cls.gc.TEST_MODE = True | 758 cls.gc.TEST_MODE = True |
742 | 759 |
743 REPO_SCHEMA = """ | 760 REPO_SCHEMA = """ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '') | 819 self.assertEquals(self.repo.git('status', '--porcelain').stdout, '') |
803 | 820 |
804 # Thaw it out! | 821 # Thaw it out! |
805 self.assertIsNone(self.gc.thaw()) | 822 self.assertIsNone(self.gc.thaw()) |
806 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything | 823 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything |
807 | 824 |
808 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) | 825 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) |
809 | 826 |
810 self.repo.run(inner) | 827 self.repo.run(inner) |
811 | 828 |
829 def testTooBig(self): | |
830 def inner(): | |
831 self.repo.git('config', 'depot-tools.freeze-size-limit', '1') | |
832 with open('bigfile', 'w') as f: | |
tandrii(chromium)
2016/06/21 14:43:37
3 files, 400KB each, please :)
agable
2016/06/22 11:16:51
Added another test case, which fails without respo
tandrii(chromium)
2016/06/22 14:20:50
Acknowledged.
| |
833 chunk = 'NERDFACE' * 1024 | |
834 for _ in xrange(128 * 2 + 1): # Just over 2 mb | |
835 f.write(chunk) | |
836 _, err = self.repo.capture_stdio(self.gc.freeze) | |
837 self.assertIn('too much untracked+unignored', err) | |
838 | |
839 self.repo.run(inner) | |
840 | |
841 def testMerge(self): | |
842 def inner(): | |
843 self.repo.git('checkout', '-b', 'bad_merge_branch') | |
844 with open('bad_merge', 'w') as f: | |
845 f.write('bad_merge_left') | |
846 self.repo.git('add', 'bad_merge') | |
847 self.repo.git('commit', '-m', 'bad_merge') | |
848 | |
849 self.repo.git('checkout', 'branch_D') | |
850 with open('bad_merge', 'w') as f: | |
851 f.write('bad_merge_right') | |
852 self.repo.git('add', 'bad_merge') | |
853 self.repo.git('commit', '-m', 'bad_merge_d') | |
854 | |
855 self.repo.git('merge', 'bad_merge_branch') | |
856 | |
857 _, err = self.repo.capture_stdio(self.gc.freeze) | |
858 self.assertIn('Cannot freeze unmerged changes', err) | |
859 | |
860 self.repo.run(inner) | |
861 | |
812 | 862 |
813 class GitMakeWorkdir(git_test_utils.GitRepoReadOnlyTestBase, GitCommonTestBase): | 863 class GitMakeWorkdir(git_test_utils.GitRepoReadOnlyTestBase, GitCommonTestBase): |
814 def setUp(self): | 864 def setUp(self): |
815 self._tempdir = tempfile.mkdtemp() | 865 self._tempdir = tempfile.mkdtemp() |
816 | 866 |
817 def tearDown(self): | 867 def tearDown(self): |
818 shutil.rmtree(self._tempdir) | 868 shutil.rmtree(self._tempdir) |
819 | 869 |
820 REPO_SCHEMA = """ | 870 REPO_SCHEMA = """ |
821 A | 871 A |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 self.repo.show_commit('A', format_string='%cn %ci')) | 912 self.repo.show_commit('A', format_string='%cn %ci')) |
863 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000', | 913 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000', |
864 self.repo.show_commit('B', format_string='%an %ai')) | 914 self.repo.show_commit('B', format_string='%an %ai')) |
865 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000', | 915 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000', |
866 self.repo.show_commit('B', format_string='%cn %ci')) | 916 self.repo.show_commit('B', format_string='%cn %ci')) |
867 | 917 |
868 | 918 |
869 if __name__ == '__main__': | 919 if __name__ == '__main__': |
870 sys.exit(coverage_utils.covered_main( | 920 sys.exit(coverage_utils.covered_main( |
871 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) | 921 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) |
OLD | NEW |