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

Side by Side Diff: tests/git_common_test.py

Issue 509843002: Give git map-branches extra information behind -v and -vv flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: add # pragma: no cover to compensate for git < 1.9 Created 6 years, 3 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 | « git_map_branches.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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 self.repo['D'], 200 self.repo['D'],
201 self.repo['A'], 201 self.repo['A'],
202 self.repo['B'], 202 self.repo['B'],
203 self.repo['E'], 203 self.repo['E'],
204 self.repo['C'], 204 self.repo['C'],
205 ], ret) 205 ], ret)
206 self.assertEquals( 206 self.assertEquals(
207 self.repo.run(self.gc.hash_one, 'branch_D'), 207 self.repo.run(self.gc.hash_one, 'branch_D'),
208 self.repo['D'] 208 self.repo['D']
209 ) 209 )
210 self.assertTrue(self.repo['D'].startswith(
211 self.repo.run(self.gc.hash_one, 'branch_D', short=True)))
210 212
211 def testStream(self): 213 def testStream(self):
212 items = set(self.repo.commit_map.itervalues()) 214 items = set(self.repo.commit_map.itervalues())
213 215
214 def testfn(): 216 def testfn():
215 for line in self.gc.run_stream('log', '--format=%H').xreadlines(): 217 for line in self.gc.run_stream('log', '--format=%H').xreadlines():
216 line = line.strip() 218 line = line.strip()
217 self.assertIn(line, items) 219 self.assertIn(line, items)
218 items.remove(line) 220 items.remove(line)
219 221
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 self.assertEquals('catfood', self.repo.run(self.gc.root)) 361 self.assertEquals('catfood', self.repo.run(self.gc.root))
360 362
361 def testUpstream(self): 363 def testUpstream(self):
362 self.repo.git('commit', '--allow-empty', '-am', 'foooooo') 364 self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
363 self.assertEquals(self.repo.run(self.gc.upstream, 'bobly'), None) 365 self.assertEquals(self.repo.run(self.gc.upstream, 'bobly'), None)
364 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None) 366 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None)
365 self.repo.git('checkout', '-tb', 'happybranch', 'master') 367 self.repo.git('checkout', '-tb', 'happybranch', 'master')
366 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'), 368 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'),
367 'master') 369 'master')
368 370
371 def testNormalizedVersion(self):
372 self.assertTrue(all(
373 isinstance(x, int) for x in self.repo.run(self.gc.get_git_version)))
374
375 def testGetAllTrackingInfo(self):
376 self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
377 self.repo.git('checkout', '-tb', 'happybranch', 'master')
378 self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
379 self.repo.git('checkout', '-tb', 'child', 'happybranch')
380
381 self.repo.git('checkout', '-tb', 'to_delete', 'master')
382 self.repo.git('checkout', '-tb', 'parent_gone', 'to_delete')
383 self.repo.git('branch', '-D', 'to_delete')
384
385 actual = self.repo.run(self.gc.get_all_tracking_info)
386 supports_track = (
387 self.repo.run(self.gc.get_git_version)
388 >= self.gc.MIN_UPSTREAM_TRACK_GIT_VERSION)
389
390 expected = {
391 'happybranch': (
392 self.repo.run(self.gc.hash_one, 'happybranch', short=True),
393 'master',
394 1 if supports_track else None,
395 None
396 ),
397 'child': (
398 self.repo.run(self.gc.hash_one, 'child', short=True),
399 'happybranch',
400 None,
401 None
402 ),
403 'master': (
404 self.repo.run(self.gc.hash_one, 'master', short=True),
405 '',
406 None,
407 None
408 ),
409 '': None,
410 'parent_gone': (
411 self.repo.run(self.gc.hash_one, 'parent_gone', short=True),
412 'to_delete',
413 1 if supports_track else None,
414 None
415 ),
416 'to_delete': None
417 }
418 self.assertEquals(expected, actual)
419
369 420
370 class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase, 421 class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase,
371 GitCommonTestBase): 422 GitCommonTestBase):
372 REPO_SCHEMA = """ 423 REPO_SCHEMA = """
373 A B C D E F G 424 A B C D E F G
374 B H I J K 425 B H I J K
375 J L 426 J L
376 427
377 X Y Z 428 X Y Z
378 429
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 704
654 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) 705 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1)
655 706
656 self.repo.run(inner) 707 self.repo.run(inner)
657 708
658 709
659 if __name__ == '__main__': 710 if __name__ == '__main__':
660 sys.exit(coverage_utils.covered_main( 711 sys.exit(coverage_utils.covered_main(
661 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') 712 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')
662 )) 713 ))
OLDNEW
« no previous file with comments | « git_map_branches.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698