| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. | 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 gclient_scm.os.path.exists(file_path).AndReturn(True) | 272 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 273 print("________ found .git directory; skipping %s" % self.relpath) | 273 print("________ found .git directory; skipping %s" % self.relpath) |
| 274 | 274 |
| 275 self.mox.ReplayAll() | 275 self.mox.ReplayAll() |
| 276 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 276 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 277 relpath=self.relpath) | 277 relpath=self.relpath) |
| 278 file_list = [] | 278 file_list = [] |
| 279 scm.update(options, self.args, file_list) | 279 scm.update(options, self.args, file_list) |
| 280 | 280 |
| 281 | 281 |
| 282 class GitWrapperTestCase(SuperMoxBaseTestBase): | 282 class GitWrapperTestCase(BaseTestCase): |
| 283 """This class doesn't use pymox.""" | 283 """This class doesn't use pymox.""" |
| 284 class OptionsObject(object): | 284 class OptionsObject(object): |
| 285 def __init__(self, test_case, verbose=False, revision=None): | 285 def __init__(self, test_case, verbose=False, revision=None): |
| 286 self.verbose = verbose | 286 self.verbose = verbose |
| 287 self.revision = revision | 287 self.revision = revision |
| 288 self.manually_grab_svn_rev = True | 288 self.manually_grab_svn_rev = True |
| 289 self.deps_os = None | 289 self.deps_os = None |
| 290 self.force = False | 290 self.force = False |
| 291 self.nohooks = False | 291 self.nohooks = False |
| 292 | 292 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 expected_file_list = [gclient_scm.os.path.join(self.base_path, x) | 499 expected_file_list = [gclient_scm.os.path.join(self.base_path, x) |
| 500 for x in ['a', 'b']] | 500 for x in ['a', 'b']] |
| 501 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 501 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 502 relpath=self.relpath) | 502 relpath=self.relpath) |
| 503 file_list = [] | 503 file_list = [] |
| 504 scm.update(options, (), file_list) | 504 scm.update(options, (), file_list) |
| 505 self.assertEquals(file_list, expected_file_list) | 505 self.assertEquals(file_list, expected_file_list) |
| 506 self.assertEquals(scm.revinfo(options, (), None), | 506 self.assertEquals(scm.revinfo(options, (), None), |
| 507 'a7142dc9f0009350b96a11f372b6ea658592aa95') | 507 'a7142dc9f0009350b96a11f372b6ea658592aa95') |
| 508 | 508 |
| 509 def testUpdateConflict(self): |
| 510 if not self.enabled: |
| 511 return |
| 512 options = self.Options() |
| 513 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 514 relpath=self.relpath) |
| 515 file_path = gclient_scm.os.path.join(self.base_path, 'b') |
| 516 f = open(file_path, 'w').writelines('conflict\n') |
| 517 scm._Run(['commit', '-am', 'test']) |
| 518 exception = \ |
| 519 '\n____ .\n' \ |
| 520 '\nConflict while rebasing this branch.\n' \ |
| 521 'Fix the conflict and run gclient again.\n' \ |
| 522 'See man git-rebase for details.\n' |
| 523 self.assertRaisesError(exception, scm.update, options, (), []) |
| 524 exception = \ |
| 525 '\n____ .\n' \ |
| 526 '\tAlready in a conflict, i.e. (no branch).\n' \ |
| 527 '\tFix the conflict and run gclient again.\n' \ |
| 528 '\tOr to abort run:\n\t\tgit-rebase --abort\n' \ |
| 529 '\tSee man git-rebase for details.\n' |
| 530 self.assertRaisesError(exception, scm.update, options, (), []) |
| 531 |
| 509 def testRevinfo(self): | 532 def testRevinfo(self): |
| 510 if not self.enabled: | 533 if not self.enabled: |
| 511 return | 534 return |
| 512 options = self.Options() | 535 options = self.Options() |
| 513 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 536 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 514 relpath=self.relpath) | 537 relpath=self.relpath) |
| 515 rev_info = scm.revinfo(options, (), None) | 538 rev_info = scm.revinfo(options, (), None) |
| 516 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 539 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 517 | 540 |
| 518 | 541 |
| 519 if __name__ == '__main__': | 542 if __name__ == '__main__': |
| 520 import unittest | 543 import unittest |
| 521 unittest.main() | 544 unittest.main() |
| 522 | 545 |
| 523 # vim: ts=2:sw=2:tw=80:et: | 546 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |