| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 self.assertEquals(self.repo.run(self.gc.upstream, 'bobly'), None) | 365 self.assertEquals(self.repo.run(self.gc.upstream, 'bobly'), None) |
| 366 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None) | 366 self.assertEquals(self.repo.run(self.gc.upstream, 'master'), None) |
| 367 self.repo.git('checkout', '-tb', 'happybranch', 'master') | 367 self.repo.git('checkout', '-tb', 'happybranch', 'master') |
| 368 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'), | 368 self.assertEquals(self.repo.run(self.gc.upstream, 'happybranch'), |
| 369 'master') | 369 'master') |
| 370 | 370 |
| 371 def testNormalizedVersion(self): | 371 def testNormalizedVersion(self): |
| 372 self.assertTrue(all( | 372 self.assertTrue(all( |
| 373 isinstance(x, int) for x in self.repo.run(self.gc.get_git_version))) | 373 isinstance(x, int) for x in self.repo.run(self.gc.get_git_version))) |
| 374 | 374 |
| 375 def testGetAllTrackingInfo(self): | 375 def testGetBranchesInfo(self): |
| 376 self.repo.git('commit', '--allow-empty', '-am', 'foooooo') | 376 self.repo.git('commit', '--allow-empty', '-am', 'foooooo') |
| 377 self.repo.git('checkout', '-tb', 'happybranch', 'master') | 377 self.repo.git('checkout', '-tb', 'happybranch', 'master') |
| 378 self.repo.git('commit', '--allow-empty', '-am', 'foooooo') | 378 self.repo.git('commit', '--allow-empty', '-am', 'foooooo') |
| 379 self.repo.git('checkout', '-tb', 'child', 'happybranch') | 379 self.repo.git('checkout', '-tb', 'child', 'happybranch') |
| 380 | 380 |
| 381 self.repo.git('checkout', '-tb', 'to_delete', 'master') | 381 self.repo.git('checkout', '-tb', 'to_delete', 'master') |
| 382 self.repo.git('checkout', '-tb', 'parent_gone', 'to_delete') | 382 self.repo.git('checkout', '-tb', 'parent_gone', 'to_delete') |
| 383 self.repo.git('branch', '-D', 'to_delete') | 383 self.repo.git('branch', '-D', 'to_delete') |
| 384 | 384 |
| 385 actual = self.repo.run(self.gc.get_all_tracking_info) | |
| 386 supports_track = ( | 385 supports_track = ( |
| 387 self.repo.run(self.gc.get_git_version) | 386 self.repo.run(self.gc.get_git_version) |
| 388 >= self.gc.MIN_UPSTREAM_TRACK_GIT_VERSION) | 387 >= self.gc.MIN_UPSTREAM_TRACK_GIT_VERSION) |
| 388 actual = self.repo.run(self.gc.get_branches_info, supports_track) |
| 389 | 389 |
| 390 expected = { | 390 expected = { |
| 391 'happybranch': ( | 391 'happybranch': ( |
| 392 self.repo.run(self.gc.hash_one, 'happybranch', short=True), | 392 self.repo.run(self.gc.hash_one, 'happybranch', short=True), |
| 393 'master', | 393 'master', |
| 394 1 if supports_track else None, | 394 1 if supports_track else None, |
| 395 None | 395 None |
| 396 ), | 396 ), |
| 397 'child': ( | 397 'child': ( |
| 398 self.repo.run(self.gc.hash_one, 'child', short=True), | 398 self.repo.run(self.gc.hash_one, 'child', short=True), |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 | 704 |
| 705 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) | 705 self.assertEquals(self.repo.git('status', '--porcelain').stdout, STATUS_1) |
| 706 | 706 |
| 707 self.repo.run(inner) | 707 self.repo.run(inner) |
| 708 | 708 |
| 709 | 709 |
| 710 if __name__ == '__main__': | 710 if __name__ == '__main__': |
| 711 sys.exit(coverage_utils.covered_main( | 711 sys.exit(coverage_utils.covered_main( |
| 712 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') | 712 os.path.join(DEPOT_TOOLS_ROOT, 'git_common.py') |
| 713 )) | 713 )) |
| OLD | NEW |