| 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. |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 | 1070 |
| 1071 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1071 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1072 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1072 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1073 ).AndReturn(True) | 1073 ).AndReturn(True) |
| 1074 | 1074 |
| 1075 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1075 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| 1076 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( | 1076 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| 1077 ).AndReturn(False) | 1077 ).AndReturn(False) |
| 1078 | 1078 |
| 1079 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) | 1079 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) |
| 1080 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 1080 | 1081 |
| 1081 self.mox.ReplayAll() | 1082 self.mox.ReplayAll() |
| 1082 | 1083 |
| 1083 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1084 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 1084 relpath=self.relpath) | 1085 relpath=self.relpath) |
| 1085 # A [fake] git sha1 with a git repo should work (this is in the case that | 1086 # A [fake] git sha1 with a git repo should work (this is in the case that |
| 1086 # the LKGR gets flipped to git sha1's some day). | 1087 # the LKGR gets flipped to git sha1's some day). |
| 1087 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options), | 1088 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options), |
| 1088 self.fake_hash_1) | 1089 self.fake_hash_1) |
| 1089 # An SVN rev with an existing purely git repo should raise an exception. | 1090 # An SVN rev with an existing purely git repo should raise an exception. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1111 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev. | 1112 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev. |
| 1112 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) | 1113 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) |
| 1113 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1114 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
| 1114 cwd=self.base_path).AndReturn('blah') | 1115 cwd=self.base_path).AndReturn('blah') |
| 1115 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) | 1116 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) |
| 1116 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1117 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
| 1117 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') | 1118 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') |
| 1118 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1119 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
| 1119 cwd=self.base_path).AndRaise(error) | 1120 cwd=self.base_path).AndRaise(error) |
| 1120 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1121 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
| 1122 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) |
| 1121 | 1123 |
| 1122 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1124 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| 1123 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( | 1125 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| 1124 ).AndReturn(True) | 1126 ).AndReturn(True) |
| 1125 | 1127 |
| 1126 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1128 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1127 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1129 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1128 ).AndReturn(True) | 1130 ).AndReturn(True) |
| 1129 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big | 1131 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
| 1130 ).AndReturn(False) | 1132 ).MultipleTimes(2).AndReturn(False) |
| 1131 | 1133 |
| 1132 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 1134 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 1133 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) | 1135 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
| 1134 | 1136 |
| 1135 self.mox.ReplayAll() | 1137 self.mox.ReplayAll() |
| 1136 | 1138 |
| 1137 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 1139 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1138 relpath=self.relpath) | 1140 relpath=self.relpath) |
| 1139 # Without an existing checkout, this should fail. | 1141 # Without an existing checkout, this should fail. |
| 1140 # TODO(dbeam) Fix this. http://crbug.com/109184 | 1142 # TODO(dbeam) Fix this. http://crbug.com/109184 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1182 |
| 1181 if __name__ == '__main__': | 1183 if __name__ == '__main__': |
| 1182 if '-v' in sys.argv: | 1184 if '-v' in sys.argv: |
| 1183 logging.basicConfig( | 1185 logging.basicConfig( |
| 1184 level=logging.DEBUG, | 1186 level=logging.DEBUG, |
| 1185 format='%(asctime).19s %(levelname)s %(filename)s:' | 1187 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1186 '%(lineno)s %(message)s') | 1188 '%(lineno)s %(message)s') |
| 1187 unittest.main() | 1189 unittest.main() |
| 1188 | 1190 |
| 1189 # vim: ts=2:sw=2:tw=80:et: | 1191 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |