OLD | NEW |
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 Loading... |
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 Loading... |
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 )) |
OLD | NEW |