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

Side by Side Diff: tests/git_common_test.py

Issue 238213006: Abort git tools if git repo has too many local branches. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: change message Created 6 years, 8 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_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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 COMMIT_L = {'file': {'data': 'L'}} 385 COMMIT_L = {'file': {'data': 'L'}}
386 386
387 def setUp(self): 387 def setUp(self):
388 super(GitMutableStructuredTest, self).setUp() 388 super(GitMutableStructuredTest, self).setUp()
389 self.repo.git('branch', '--set-upstream-to', 'root_X', 'branch_Z') 389 self.repo.git('branch', '--set-upstream-to', 'root_X', 'branch_Z')
390 self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K') 390 self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K')
391 self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L') 391 self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L')
392 self.repo.git('branch', '--set-upstream-to', 'root_A', 'branch_G') 392 self.repo.git('branch', '--set-upstream-to', 'root_A', 'branch_G')
393 self.repo.git('branch', '--set-upstream-to', 'root_X', 'root_A') 393 self.repo.git('branch', '--set-upstream-to', 'root_X', 'root_A')
394 394
395 def testTooManyBranches(self):
396 for i in xrange(30):
397 self.repo.git('branch', 'a'*i)
398
399 with self.assertRaises(SystemExit):
400 self.repo.run(list, self.gc.branches())
401
402 self.repo.git('config', 'depot-tools.branch-limit', 'cat')
403
404 with self.assertRaises(SystemExit):
405 self.repo.run(list, self.gc.branches())
406
407 self.repo.git('config', 'depot-tools.branch-limit', '100')
408
409 # should not raise
410 self.assertEqual(36, len(self.repo.run(list, self.gc.branches())))
411
395 def testMergeBase(self): 412 def testMergeBase(self):
396 self.repo.git('checkout', 'branch_K') 413 self.repo.git('checkout', 'branch_K')
397 414
398 self.assertEqual( 415 self.assertEqual(
399 self.repo['B'], 416 self.repo['B'],
400 self.repo.run(self.gc.get_or_create_merge_base, 'branch_K', 'branch_G') 417 self.repo.run(self.gc.get_or_create_merge_base, 'branch_K', 'branch_G')
401 ) 418 )
402 419
403 self.assertEqual( 420 self.assertEqual(
404 self.repo['J'], 421 self.repo['J'],
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 629
613 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) 630 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1)
614 631
615 self.repo.run(inner) 632 self.repo.run(inner)
616 633
617 634
618 if __name__ == '__main__': 635 if __name__ == '__main__':
619 sys.exit(coverage_utils.covered_main( 636 sys.exit(coverage_utils.covered_main(
620 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') 637 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py')
621 )) 638 ))
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