| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1103 | 8 # pylint: disable=E1103 |
| 9 | 9 |
| 10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
| 11 from os import rename | |
| 12 from shutil import rmtree | 11 from shutil import rmtree |
| 13 from subprocess import Popen, PIPE, STDOUT | 12 from subprocess import Popen, PIPE, STDOUT |
| 14 | 13 |
| 15 import logging | 14 import logging |
| 16 import os | 15 import os |
| 17 import sys | 16 import sys |
| 18 import tempfile | 17 import tempfile |
| 19 import unittest | 18 import unittest |
| 20 import __builtin__ | 19 import __builtin__ |
| 21 | 20 |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 exception = ('Conflict while rebasing this branch.\n' | 1018 exception = ('Conflict while rebasing this branch.\n' |
| 1020 'Fix the conflict and run gclient again.\n' | 1019 'Fix the conflict and run gclient again.\n' |
| 1021 'See \'man git-rebase\' for details.\n') | 1020 'See \'man git-rebase\' for details.\n') |
| 1022 self.assertRaisesError(exception, scm.update, options, (), []) | 1021 self.assertRaisesError(exception, scm.update, options, (), []) |
| 1023 exception = ('\n____ . at refs/heads/master\n' | 1022 exception = ('\n____ . at refs/heads/master\n' |
| 1024 '\tYou have unstaged changes.\n' | 1023 '\tYou have unstaged changes.\n' |
| 1025 '\tPlease commit, stash, or reset.\n') | 1024 '\tPlease commit, stash, or reset.\n') |
| 1026 self.assertRaisesError(exception, scm.update, options, (), []) | 1025 self.assertRaisesError(exception, scm.update, options, (), []) |
| 1027 sys.stdout.close() | 1026 sys.stdout.close() |
| 1028 | 1027 |
| 1029 def testUpdateNotGit(self): | |
| 1030 if not self.enabled: | |
| 1031 return | |
| 1032 options = self.Options() | |
| 1033 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | |
| 1034 relpath=self.relpath) | |
| 1035 git_path = join(self.base_path, '.git') | |
| 1036 rename(git_path, git_path + 'foo') | |
| 1037 exception = ('\n____ . at refs/heads/master\n' | |
| 1038 '\tPath is not a git repo. No .git dir.\n' | |
| 1039 '\tTo resolve:\n' | |
| 1040 '\t\trm -rf .\n' | |
| 1041 '\tAnd run gclient sync again\n') | |
| 1042 self.assertRaisesError(exception, scm.update, options, (), []) | |
| 1043 | |
| 1044 def testRevinfo(self): | 1028 def testRevinfo(self): |
| 1045 if not self.enabled: | 1029 if not self.enabled: |
| 1046 return | 1030 return |
| 1047 options = self.Options() | 1031 options = self.Options() |
| 1048 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1032 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 1049 relpath=self.relpath) | 1033 relpath=self.relpath) |
| 1050 rev_info = scm.revinfo(options, (), None) | 1034 rev_info = scm.revinfo(options, (), None) |
| 1051 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 1035 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 1052 | 1036 |
| 1053 | 1037 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 | 1180 |
| 1197 if __name__ == '__main__': | 1181 if __name__ == '__main__': |
| 1198 if '-v' in sys.argv: | 1182 if '-v' in sys.argv: |
| 1199 logging.basicConfig( | 1183 logging.basicConfig( |
| 1200 level=logging.DEBUG, | 1184 level=logging.DEBUG, |
| 1201 format='%(asctime).19s %(levelname)s %(filename)s:' | 1185 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1202 '%(lineno)s %(message)s') | 1186 '%(lineno)s %(message)s') |
| 1203 unittest.main() | 1187 unittest.main() |
| 1204 | 1188 |
| 1205 # vim: ts=2:sw=2:tw=80:et: | 1189 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |