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

Side by Side Diff: tests/git_common_test.py

Issue 1629253002: git hyper-blame: Added approx. line number translation. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@git-hyper-blame
Patch Set: Added Caveats section to man page. Created 4 years, 10 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
« no previous file with comments | « man/src/git-hyper-blame.txt ('k') | tests/git_hyper_blame_test.py » ('j') | 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 self.assertIsNone(self.repo.run(cur_branch_out_of_git)) 247 self.assertIsNone(self.repo.run(cur_branch_out_of_git))
248 248
249 self.repo.git('checkout', 'branch_D') 249 self.repo.git('checkout', 'branch_D')
250 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D') 250 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D')
251 251
252 def testBranches(self): 252 def testBranches(self):
253 # This check fails with git 2.4 (see crbug.com/487172) 253 # This check fails with git 2.4 (see crbug.com/487172)
254 self.assertEqual(self.repo.run(set, self.gc.branches()), 254 self.assertEqual(self.repo.run(set, self.gc.branches()),
255 {'master', 'branch_D', 'root_A'}) 255 {'master', 'branch_D', 'root_A'})
256 256
257 def testDiff(self):
258 # Get the names of the blobs being compared (to avoid hard-coding).
259 c_blob_short = self.repo.git('rev-parse', '--short',
260 'tag_C:some/files/file2').stdout.strip()
261 d_blob_short = self.repo.git('rev-parse', '--short',
262 'tag_D:some/files/file2').stdout.strip()
263 expected_output = [
264 'diff --git a/some/files/file2 b/some/files/file2',
265 'index %s..%s 100755' % (c_blob_short, d_blob_short),
266 '--- a/some/files/file2',
267 '+++ b/some/files/file2',
268 '@@ -1 +1,2 @@',
269 ' file2 - vanilla',
270 '+file2 - merged']
271 self.assertEqual(expected_output,
272 self.repo.run(self.gc.diff, 'tag_C', 'tag_D').split('\n'))
273
257 def testDormant(self): 274 def testDormant(self):
258 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master')) 275 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master'))
259 self.repo.git('config', 'branch.master.dormant', 'true') 276 self.repo.git('config', 'branch.master.dormant', 'true')
260 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master')) 277 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master'))
261 278
262 def testBlame(self): 279 def testBlame(self):
263 def get_porcelain_for_commit(commit_name, lines): 280 def get_porcelain_for_commit(commit_name, lines):
264 format_string = ('%H {}\nauthor %an\nauthor-mail <%ae>\nauthor-time %at\n' 281 format_string = ('%H {}\nauthor %an\nauthor-mail <%ae>\nauthor-time %at\n'
265 'author-tz +0000\ncommitter %cn\ncommitter-mail <%ce>\n' 282 'author-tz +0000\ncommitter %cn\ncommitter-mail <%ce>\n'
266 'committer-time %ct\ncommitter-tz +0000\nsummary {}') 283 'committer-time %ct\ncommitter-tz +0000\nsummary {}')
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 self.repo.show_commit('A', format_string='%cn %ci')) 858 self.repo.show_commit('A', format_string='%cn %ci'))
842 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000', 859 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000',
843 self.repo.show_commit('B', format_string='%an %ai')) 860 self.repo.show_commit('B', format_string='%an %ai'))
844 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000', 861 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000',
845 self.repo.show_commit('B', format_string='%cn %ci')) 862 self.repo.show_commit('B', format_string='%cn %ci'))
846 863
847 864
848 if __name__ == '__main__': 865 if __name__ == '__main__':
849 sys.exit(coverage_utils.covered_main( 866 sys.exit(coverage_utils.covered_main(
850 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) 867 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')))
OLDNEW
« no previous file with comments | « man/src/git-hyper-blame.txt ('k') | tests/git_hyper_blame_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698