Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: tests/git_common_test.py

Issue 1527403002: Better error checking in git freeze (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Add a test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 self.repo.git('add', 'bad_merge') 852 self.repo.git('add', 'bad_merge')
853 self.repo.git('commit', '-m', 'bad_merge_d') 853 self.repo.git('commit', '-m', 'bad_merge_d')
854 854
855 self.repo.git('merge', 'bad_merge_branch') 855 self.repo.git('merge', 'bad_merge_branch')
856 856
857 _, err = self.repo.capture_stdio(self.gc.freeze) 857 _, err = self.repo.capture_stdio(self.gc.freeze)
858 self.assertIn('Cannot freeze unmerged changes', err) 858 self.assertIn('Cannot freeze unmerged changes', err)
859 859
860 self.repo.run(inner) 860 self.repo.run(inner)
861 861
862 def testAddError(self):
863 def inner():
864 self.repo.git('checkout', '-b', 'unreadable_file_branch')
865 with open('bad_file', 'w') as f:
866 f.write('some text')
867 os.chmod('bad_file', 0111)
868 ret = self.repo.run(self.gc.freeze)
869 self.assertIn('Failed to index some unindexed files.', ret)
870
871 self.repo.run(inner)
872
862 873
863 class GitMakeWorkdir(git_test_utils.GitRepoReadOnlyTestBase, GitCommonTestBase): 874 class GitMakeWorkdir(git_test_utils.GitRepoReadOnlyTestBase, GitCommonTestBase):
864 def setUp(self): 875 def setUp(self):
865 self._tempdir = tempfile.mkdtemp() 876 self._tempdir = tempfile.mkdtemp()
866 877
867 def tearDown(self): 878 def tearDown(self):
868 shutil.rmtree(self._tempdir) 879 shutil.rmtree(self._tempdir)
869 880
870 REPO_SCHEMA = """ 881 REPO_SCHEMA = """
871 A 882 A
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 self.repo.show_commit('A', format_string='%cn %ci')) 923 self.repo.show_commit('A', format_string='%cn %ci'))
913 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000', 924 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000',
914 self.repo.show_commit('B', format_string='%an %ai')) 925 self.repo.show_commit('B', format_string='%an %ai'))
915 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000', 926 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000',
916 self.repo.show_commit('B', format_string='%cn %ci')) 927 self.repo.show_commit('B', format_string='%cn %ci'))
917 928
918 929
919 if __name__ == '__main__': 930 if __name__ == '__main__':
920 sys.exit(coverage_utils.covered_main( 931 sys.exit(coverage_utils.covered_main(
921 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) 932 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')))
OLDNEW
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698