| 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 # |
| 11 # Unless required by applicable law or agreed to in writing, software | 11 # Unless required by applicable law or agreed to in writing, software |
| 12 # distributed under the License is distributed on an "AS IS" BASIS, | 12 # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 # See the License for the specific language governing permissions and | 14 # See the License for the specific language governing permissions and |
| 15 # limitations under the License. | 15 # limitations under the License. |
| 16 | 16 |
| 17 """Unit tests for gclient_scm.py.""" | 17 """Unit tests for gclient_scm.py.""" |
| 18 | 18 |
| 19 import os |
| 19 import shutil | 20 import shutil |
| 20 # Import it before super_mox to keep a valid reference. | 21 # Import it before super_mox to keep a valid reference. |
| 21 from subprocess import Popen, PIPE, STDOUT | 22 from subprocess import Popen, PIPE, STDOUT |
| 22 import tempfile | 23 import tempfile |
| 23 | 24 |
| 24 import gclient_scm | 25 import gclient_scm |
| 25 from gclient_test import BaseTestCase as GCBaseTestCase | 26 from gclient_test import BaseTestCase as GCBaseTestCase |
| 26 from super_mox import mox, SuperMoxBaseTestBase | 27 from super_mox import mox, SuperMoxBaseTestBase |
| 27 | 28 |
| 28 | 29 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 'See man git-rebase for details.\n' | 535 'See man git-rebase for details.\n' |
| 535 self.assertRaisesError(exception, scm.update, options, (), []) | 536 self.assertRaisesError(exception, scm.update, options, (), []) |
| 536 exception = \ | 537 exception = \ |
| 537 '\n____ .\n' \ | 538 '\n____ .\n' \ |
| 538 '\tAlready in a conflict, i.e. (no branch).\n' \ | 539 '\tAlready in a conflict, i.e. (no branch).\n' \ |
| 539 '\tFix the conflict and run gclient again.\n' \ | 540 '\tFix the conflict and run gclient again.\n' \ |
| 540 '\tOr to abort run:\n\t\tgit-rebase --abort\n' \ | 541 '\tOr to abort run:\n\t\tgit-rebase --abort\n' \ |
| 541 '\tSee man git-rebase for details.\n' | 542 '\tSee man git-rebase for details.\n' |
| 542 self.assertRaisesError(exception, scm.update, options, (), []) | 543 self.assertRaisesError(exception, scm.update, options, (), []) |
| 543 | 544 |
| 545 def testUpdateNotGit(self): |
| 546 if not self.enabled: |
| 547 return |
| 548 options = self.Options() |
| 549 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 550 relpath=self.relpath) |
| 551 git_path = gclient_scm.os.path.join(self.base_path, '.git') |
| 552 os.rename(git_path, git_path + 'foo') |
| 553 exception = \ |
| 554 '\n____ .\n' \ |
| 555 '\tPath is not a git repo. No .git dir.\n' \ |
| 556 '\tTo resolve:\n' \ |
| 557 '\t\trm -rf .\n' \ |
| 558 '\tAnd run gclient sync again\n' |
| 559 self.assertRaisesError(exception, scm.update, options, (), []) |
| 560 |
| 544 def testRevinfo(self): | 561 def testRevinfo(self): |
| 545 if not self.enabled: | 562 if not self.enabled: |
| 546 return | 563 return |
| 547 options = self.Options() | 564 options = self.Options() |
| 548 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 565 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 549 relpath=self.relpath) | 566 relpath=self.relpath) |
| 550 rev_info = scm.revinfo(options, (), None) | 567 rev_info = scm.revinfo(options, (), None) |
| 551 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 568 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 552 | 569 |
| 553 | 570 |
| 554 if __name__ == '__main__': | 571 if __name__ == '__main__': |
| 555 import unittest | 572 import unittest |
| 556 unittest.main() | 573 unittest.main() |
| 557 | 574 |
| 558 # vim: ts=2:sw=2:tw=80:et: | 575 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |