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

Side by Side Diff: tests/git_common_test.py

Issue 1559943003: Added git hyper-blame, a tool that skips unwanted commits in git blame. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix comment. 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
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 COMMIT_A = { 169 COMMIT_A = {
170 'some/files/file1': {'data': 'file1'}, 170 'some/files/file1': {'data': 'file1'},
171 'some/files/file2': {'data': 'file2'}, 171 'some/files/file2': {'data': 'file2'},
172 'some/files/file3': {'data': 'file3'}, 172 'some/files/file3': {'data': 'file3'},
173 'some/other/file': {'data': 'otherfile'}, 173 'some/other/file': {'data': 'otherfile'},
174 } 174 }
175 175
176 COMMIT_C = { 176 COMMIT_C = {
177 'some/files/file2': { 177 'some/files/file2': {
178 'mode': 0755, 178 'mode': 0755,
179 'data': 'file2 - vanilla'}, 179 'data': 'file2 - vanilla\n'},
180 } 180 }
181 181
182 COMMIT_E = { 182 COMMIT_E = {
183 'some/files/file2': {'data': 'file2 - merged'}, 183 'some/files/file2': {'data': 'file2 - merged\n'},
184 } 184 }
185 185
186 COMMIT_D = { 186 COMMIT_D = {
187 'some/files/file2': {'data': 'file2 - vanilla\nfile2 - merged'}, 187 'some/files/file2': {'data': 'file2 - vanilla\nfile2 - merged\n'},
188 } 188 }
189 189
190 def testHashes(self): 190 def testHashes(self):
191 ret = self.repo.run( 191 ret = self.repo.run(
192 self.gc.hash_multi, *[ 192 self.gc.hash_multi, *[
193 'master', 193 'master',
194 'master~3', 194 'master~3',
195 self.repo['E']+'~', 195 self.repo['E']+'~',
196 self.repo['D']+'^2', 196 self.repo['D']+'^2',
197 'tag_C^{}', 197 'tag_C^{}',
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 testDormant(self): 257 def testDormant(self):
258 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master')) 258 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master'))
259 self.repo.git('config', 'branch.master.dormant', 'true') 259 self.repo.git('config', 'branch.master.dormant', 'true')
260 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master')) 260 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master'))
261 261
262 def testBlame(self):
263 # Expect to blame line 1 on C, line 2 on E.
264 c_short = self.repo['C'][:8]
265 c_author = self.repo.show_commit('C', format_string='%an %ai')
266 e_short = self.repo['E'][:8]
267 e_author = self.repo.show_commit('E', format_string='%an %ai')
268 expected_output = ['%s (%s 1) file2 - vanilla' % (c_short, c_author),
269 '%s (%s 2) file2 - merged' % (e_short, e_author)]
270 self.assertEqual(expected_output,
271 self.repo.run(self.gc.blame, 'some/files/file2',
272 'tag_D').split('\n'))
273
262 def testParseCommitrefs(self): 274 def testParseCommitrefs(self):
263 ret = self.repo.run( 275 ret = self.repo.run(
264 self.gc.parse_commitrefs, *[ 276 self.gc.parse_commitrefs, *[
265 'master', 277 'master',
266 'master~3', 278 'master~3',
267 self.repo['E']+'~', 279 self.repo['E']+'~',
268 self.repo['D']+'^2', 280 self.repo['D']+'^2',
269 'tag_C^{}', 281 'tag_C^{}',
270 ] 282 ]
271 ) 283 )
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 self.repo.show_commit('A', format_string='%cn %ci')) 808 self.repo.show_commit('A', format_string='%cn %ci'))
797 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000', 809 self.assertEquals('Author McAuthorly 1970-01-03 00:00:00 +0000',
798 self.repo.show_commit('B', format_string='%an %ai')) 810 self.repo.show_commit('B', format_string='%an %ai'))
799 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000', 811 self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000',
800 self.repo.show_commit('B', format_string='%cn %ci')) 812 self.repo.show_commit('B', format_string='%cn %ci'))
801 813
802 814
803 if __name__ == '__main__': 815 if __name__ == '__main__':
804 sys.exit(coverage_utils.covered_main( 816 sys.exit(coverage_utils.covered_main(
805 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) 817 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698