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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 def testCurrentBranch(self): | 224 def testCurrentBranch(self): |
225 def cur_branch_out_of_git(): | 225 def cur_branch_out_of_git(): |
226 os.chdir('..') | 226 os.chdir('..') |
227 return self.gc.current_branch() | 227 return self.gc.current_branch() |
228 self.assertIsNone(self.repo.run(cur_branch_out_of_git)) | 228 self.assertIsNone(self.repo.run(cur_branch_out_of_git)) |
229 | 229 |
230 self.repo.git('checkout', 'branch_D') | 230 self.repo.git('checkout', 'branch_D') |
231 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D') | 231 self.assertEqual(self.repo.run(self.gc.current_branch), 'branch_D') |
232 | 232 |
233 @unittest.skip('broken by git 2.4') | |
234 def testBranches(self): | 233 def testBranches(self): |
235 # This check fails with git 2.4 (see crbug.com/487172) | 234 # This check fails with git 2.4 (see crbug.com/487172) |
236 self.assertEqual(self.repo.run(set, self.gc.branches()), | 235 self.assertEqual(self.repo.run(set, self.gc.branches()), |
237 {'master', 'branch_D', 'root_A'}) | 236 {'master', 'branch_D', 'root_A'}) |
238 | 237 |
239 def testDormant(self): | 238 def testDormant(self): |
240 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master')) | 239 self.assertFalse(self.repo.run(self.gc.is_dormant, 'master')) |
241 self.repo.git('config', 'branch.master.dormant', 'true') | 240 self.repo.git('config', 'branch.master.dormant', 'true') |
242 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master')) | 241 self.assertTrue(self.repo.run(self.gc.is_dormant, 'master')) |
243 | 242 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 COMMIT_L = {'file': {'data': 'L'}} | 440 COMMIT_L = {'file': {'data': 'L'}} |
442 | 441 |
443 def setUp(self): | 442 def setUp(self): |
444 super(GitMutableStructuredTest, self).setUp() | 443 super(GitMutableStructuredTest, self).setUp() |
445 self.repo.git('branch', '--set-upstream-to', 'root_X', 'branch_Z') | 444 self.repo.git('branch', '--set-upstream-to', 'root_X', 'branch_Z') |
446 self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K') | 445 self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K') |
447 self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L') | 446 self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L') |
448 self.repo.git('branch', '--set-upstream-to', 'root_A', 'branch_G') | 447 self.repo.git('branch', '--set-upstream-to', 'root_A', 'branch_G') |
449 self.repo.git('branch', '--set-upstream-to', 'root_X', 'root_A') | 448 self.repo.git('branch', '--set-upstream-to', 'root_X', 'root_A') |
450 | 449 |
451 @unittest.skip('broken by git 2.4') | |
452 def testTooManyBranches(self): | 450 def testTooManyBranches(self): |
453 for i in xrange(30): | 451 for i in xrange(30): |
454 self.repo.git('branch', 'a'*i) | 452 self.repo.git('branch', 'a'*i) |
455 | 453 |
456 _, rslt = self.repo.capture_stdio(list, self.gc.branches()) | 454 _, rslt = self.repo.capture_stdio(list, self.gc.branches()) |
457 self.assertIn('too many branches (39/20)', rslt) | 455 self.assertIn('too many branches (39/20)', rslt) |
458 | 456 |
459 self.repo.git('config', 'depot-tools.branch-limit', 'cat') | 457 self.repo.git('config', 'depot-tools.branch-limit', 'cat') |
460 | 458 |
461 _, rslt = self.repo.capture_stdio(list, self.gc.branches()) | 459 _, rslt = self.repo.capture_stdio(list, self.gc.branches()) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 # base and recompute it. | 526 # base and recompute it. |
529 self.repo.run(self.gc.run, 'branch', '-u', 'root_A') | 527 self.repo.run(self.gc.run, 'branch', '-u', 'root_A') |
530 self.assertEqual( | 528 self.assertEqual( |
531 self.repo['A'], | 529 self.repo['A'], |
532 self.repo.run(self.gc.get_or_create_merge_base, 'branch_K') | 530 self.repo.run(self.gc.get_or_create_merge_base, 'branch_K') |
533 ) | 531 ) |
534 | 532 |
535 self.assertIsNone( | 533 self.assertIsNone( |
536 self.repo.run(self.gc.get_or_create_merge_base, 'branch_DOG')) | 534 self.repo.run(self.gc.get_or_create_merge_base, 'branch_DOG')) |
537 | 535 |
538 @unittest.skip('broken by git 2.4') | |
539 def testGetBranchTree(self): | 536 def testGetBranchTree(self): |
540 skipped, tree = self.repo.run(self.gc.get_branch_tree) | 537 skipped, tree = self.repo.run(self.gc.get_branch_tree) |
541 # This check fails with git 2.4 (see crbug.com/487172) | 538 # This check fails with git 2.4 (see crbug.com/487172) |
542 self.assertEqual(skipped, {'master', 'root_X', 'branch_DOG', 'root_CAT'}) | 539 self.assertEqual(skipped, {'master', 'root_X', 'branch_DOG', 'root_CAT'}) |
543 self.assertEqual(tree, { | 540 self.assertEqual(tree, { |
544 'branch_G': 'root_A', | 541 'branch_G': 'root_A', |
545 'root_A': 'root_X', | 542 'root_A': 'root_X', |
546 'branch_K': 'branch_G', | 543 'branch_K': 'branch_G', |
547 'branch_L': 'branch_K', | 544 'branch_L': 'branch_K', |
548 'branch_Z': 'root_X' | 545 'branch_Z': 'root_X' |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 self.assertIsNone(self.gc.thaw()) | 721 self.assertIsNone(self.gc.thaw()) |
725 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything | 722 self.assertIsNotNone(self.gc.thaw()) # One thaw should thaw everything |
726 | 723 |
727 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) | 724 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) |
728 | 725 |
729 self.repo.run(inner) | 726 self.repo.run(inner) |
730 | 727 |
731 | 728 |
732 if __name__ == '__main__': | 729 if __name__ == '__main__': |
733 sys.exit(coverage_utils.covered_main( | 730 sys.exit(coverage_utils.covered_main( |
734 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'), | 731 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py'))) |
735 required_percentage=88.0 | |
736 )) | |
OLD | NEW |