| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 # Import before super_mox to keep valid references. | 8 # Import before super_mox to keep valid references. |
| 9 from os import rename | 9 from os import rename |
| 10 from shutil import rmtree | 10 from shutil import rmtree |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 except gclient_scm.gclient_utils.Error, e: | 26 except gclient_scm.gclient_utils.Error, e: |
| 27 self.assertEquals(e.args[0], msg) | 27 self.assertEquals(e.args[0], msg) |
| 28 else: | 28 else: |
| 29 self.fail('%s not raised' % msg) | 29 self.fail('%s not raised' % msg) |
| 30 | 30 |
| 31 | 31 |
| 32 class BaseTestCase(GCBaseTestCase): | 32 class BaseTestCase(GCBaseTestCase): |
| 33 def setUp(self): | 33 def setUp(self): |
| 34 GCBaseTestCase.setUp(self) | 34 GCBaseTestCase.setUp(self) |
| 35 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'CheckCallAndFilter') | 35 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'CheckCallAndFilter') |
| 36 self.mox.StubOutWithMock(gclient_scm.gclient_utils, |
| 37 'CheckCallAndFilterAndHeader') |
| 36 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') | 38 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') |
| 37 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') | 39 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') |
| 38 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') | 40 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') |
| 39 self._CaptureSVNInfo = gclient_scm.scm.SVN.CaptureInfo | 41 self._CaptureSVNInfo = gclient_scm.scm.SVN.CaptureInfo |
| 40 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture') | 42 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture') |
| 41 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureInfo') | 43 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureInfo') |
| 42 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus') | 44 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus') |
| 43 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Run') | |
| 44 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList') | 45 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList') |
| 45 self._scm_wrapper = gclient_scm.CreateSCM | 46 self._scm_wrapper = gclient_scm.CreateSCM |
| 46 gclient_scm.sys.stdout.flush = lambda: None | 47 gclient_scm.sys.stdout.flush = lambda: None |
| 48 gclient_scm.scm.SVN.current_version = None |
| 47 | 49 |
| 48 | 50 |
| 49 class SVNWrapperTestCase(BaseTestCase): | 51 class SVNWrapperTestCase(BaseTestCase): |
| 50 class OptionsObject(object): | 52 class OptionsObject(object): |
| 51 def __init__(self, test_case, verbose=False, revision=None): | 53 def __init__(self, test_case, verbose=False, revision=None): |
| 52 self.verbose = verbose | 54 self.verbose = verbose |
| 53 self.revision = revision | 55 self.revision = revision |
| 54 self.manually_grab_svn_rev = True | 56 self.manually_grab_svn_rev = True |
| 55 self.deps_os = None | 57 self.deps_os = None |
| 56 self.force = False | 58 self.force = False |
| 57 self.reset = False | 59 self.reset = False |
| 58 self.nohooks = False | 60 self.nohooks = False |
| 61 self.stdout = gclient_scm.sys.stdout |
| 59 | 62 |
| 60 def Options(self, *args, **kwargs): | 63 def Options(self, *args, **kwargs): |
| 61 return self.OptionsObject(self, *args, **kwargs) | 64 return self.OptionsObject(self, *args, **kwargs) |
| 62 | 65 |
| 63 def setUp(self): | 66 def setUp(self): |
| 64 BaseTestCase.setUp(self) | 67 BaseTestCase.setUp(self) |
| 65 self.root_dir = self.Dir() | 68 self.root_dir = self.Dir() |
| 66 self.args = self.Args() | 69 self.args = self.Args() |
| 67 self.url = self.Url() | 70 self.url = self.Url() |
| 68 self.relpath = 'asf' | 71 self.relpath = 'asf' |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 # It'll to a checkout instead. | 127 # It'll to a checkout instead. |
| 125 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 128 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 126 ).AndReturn(False) | 129 ).AndReturn(False) |
| 127 print("\n_____ %s is missing, synching instead" % self.relpath) | 130 print("\n_____ %s is missing, synching instead" % self.relpath) |
| 128 # Checkout. | 131 # Checkout. |
| 129 gclient_scm.os.path.exists(base_path).AndReturn(False) | 132 gclient_scm.os.path.exists(base_path).AndReturn(False) |
| 130 files_list = self.mox.CreateMockAnything() | 133 files_list = self.mox.CreateMockAnything() |
| 131 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 134 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 132 ['checkout', self.url, base_path, | 135 ['checkout', self.url, base_path, |
| 133 '--force'], | 136 '--force'], |
| 134 self.root_dir, files_list) | 137 cwd=self.root_dir, |
| 138 file_list=files_list, |
| 139 stdout=options.stdout) |
| 135 | 140 |
| 136 self.mox.ReplayAll() | 141 self.mox.ReplayAll() |
| 137 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 142 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 138 relpath=self.relpath) | 143 relpath=self.relpath) |
| 139 scm.revert(options, self.args, files_list) | 144 scm.revert(options, self.args, files_list) |
| 140 | 145 |
| 141 def testRevertNone(self): | 146 def testRevertNone(self): |
| 142 options = self.Options(verbose=True) | 147 options = self.Options(verbose=True) |
| 143 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 148 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 144 gclient_scm.os.path.isdir(base_path).AndReturn(True) | 149 gclient_scm.os.path.isdir(base_path).AndReturn(True) |
| 145 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn([]) | 150 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn([]) |
| 146 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 151 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 147 ['update', '--revision', 'BASE'], | 152 ['update', '--revision', 'BASE'], |
| 148 base_path, mox.IgnoreArg()) | 153 cwd=base_path, |
| 154 file_list=mox.IgnoreArg(), |
| 155 stdout=options.stdout) |
| 149 | 156 |
| 150 self.mox.ReplayAll() | 157 self.mox.ReplayAll() |
| 151 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 158 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 152 relpath=self.relpath) | 159 relpath=self.relpath) |
| 153 file_list = [] | 160 file_list = [] |
| 154 scm.revert(options, self.args, file_list) | 161 scm.revert(options, self.args, file_list) |
| 155 | 162 |
| 156 def testRevert2Files(self): | 163 def testRevert2Files(self): |
| 157 options = self.Options(verbose=True) | 164 options = self.Options(verbose=True) |
| 158 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 165 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 159 gclient_scm.os.path.isdir(base_path).AndReturn(True) | 166 gclient_scm.os.path.isdir(base_path).AndReturn(True) |
| 160 items = [ | 167 items = [ |
| 161 ('M ', 'a'), | 168 ('M ', 'a'), |
| 162 ('A ', 'b'), | 169 ('A ', 'b'), |
| 163 ] | 170 ] |
| 164 file_path1 = gclient_scm.os.path.join(base_path, 'a') | 171 file_path1 = gclient_scm.os.path.join(base_path, 'a') |
| 165 file_path2 = gclient_scm.os.path.join(base_path, 'b') | 172 file_path2 = gclient_scm.os.path.join(base_path, 'b') |
| 166 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items) | 173 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items) |
| 167 gclient_scm.os.path.exists(file_path1).AndReturn(True) | 174 gclient_scm.os.path.exists(file_path1).AndReturn(True) |
| 168 gclient_scm.os.path.isfile(file_path1).AndReturn(True) | 175 gclient_scm.os.path.isfile(file_path1).AndReturn(True) |
| 169 gclient_scm.os.remove(file_path1) | 176 gclient_scm.os.remove(file_path1) |
| 170 gclient_scm.os.path.exists(file_path2).AndReturn(True) | 177 gclient_scm.os.path.exists(file_path2).AndReturn(True) |
| 171 gclient_scm.os.path.isfile(file_path2).AndReturn(True) | 178 gclient_scm.os.path.isfile(file_path2).AndReturn(True) |
| 172 gclient_scm.os.remove(file_path2) | 179 gclient_scm.os.remove(file_path2) |
| 173 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 180 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 174 ['update', '--revision', 'BASE'], | 181 ['update', '--revision', 'BASE'], |
| 175 base_path, mox.IgnoreArg()) | 182 cwd=base_path, |
| 183 file_list=mox.IgnoreArg(), |
| 184 stdout=options.stdout) |
| 176 print(gclient_scm.os.path.join(base_path, 'a')) | 185 print(gclient_scm.os.path.join(base_path, 'a')) |
| 177 print(gclient_scm.os.path.join(base_path, 'b')) | 186 print(gclient_scm.os.path.join(base_path, 'b')) |
| 178 | 187 |
| 179 self.mox.ReplayAll() | 188 self.mox.ReplayAll() |
| 180 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 189 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 181 relpath=self.relpath) | 190 relpath=self.relpath) |
| 182 file_list = [] | 191 file_list = [] |
| 183 scm.revert(options, self.args, file_list) | 192 scm.revert(options, self.args, file_list) |
| 184 | 193 |
| 185 def testRevertDirectory(self): | 194 def testRevertDirectory(self): |
| 186 options = self.Options(verbose=True) | 195 options = self.Options(verbose=True) |
| 187 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 196 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 188 gclient_scm.os.path.isdir(base_path).AndReturn(True) | 197 gclient_scm.os.path.isdir(base_path).AndReturn(True) |
| 189 items = [ | 198 items = [ |
| 190 ('~ ', 'a'), | 199 ('~ ', 'a'), |
| 191 ] | 200 ] |
| 192 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items) | 201 gclient_scm.scm.SVN.CaptureStatus(base_path).AndReturn(items) |
| 193 file_path = gclient_scm.os.path.join(base_path, 'a') | 202 file_path = gclient_scm.os.path.join(base_path, 'a') |
| 194 print(file_path) | 203 print(file_path) |
| 195 gclient_scm.os.path.exists(file_path).AndReturn(True) | 204 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 196 gclient_scm.os.path.isfile(file_path).AndReturn(False) | 205 gclient_scm.os.path.isfile(file_path).AndReturn(False) |
| 197 gclient_scm.os.path.islink(file_path).AndReturn(False) | 206 gclient_scm.os.path.islink(file_path).AndReturn(False) |
| 198 gclient_scm.os.path.isdir(file_path).AndReturn(True) | 207 gclient_scm.os.path.isdir(file_path).AndReturn(True) |
| 199 gclient_scm.gclient_utils.RemoveDirectory(file_path) | 208 gclient_scm.gclient_utils.RemoveDirectory(file_path) |
| 200 file_list1 = [] | 209 file_list1 = [] |
| 201 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 210 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 202 ['update', '--revision', 'BASE'], | 211 ['update', '--revision', 'BASE'], |
| 203 base_path, mox.IgnoreArg()) | 212 cwd=base_path, |
| 213 file_list=mox.IgnoreArg(), |
| 214 stdout=options.stdout) |
| 204 | 215 |
| 205 self.mox.ReplayAll() | 216 self.mox.ReplayAll() |
| 206 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 217 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 207 relpath=self.relpath) | 218 relpath=self.relpath) |
| 208 file_list2 = [] | 219 file_list2 = [] |
| 209 scm.revert(options, self.args, file_list2) | 220 scm.revert(options, self.args, file_list2) |
| 210 | 221 |
| 211 def testStatus(self): | 222 def testStatus(self): |
| 212 options = self.Options(verbose=True) | 223 options = self.Options(verbose=True) |
| 213 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 224 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 214 gclient_scm.os.path.isdir(base_path).AndReturn(True) | 225 gclient_scm.os.path.isdir(base_path).AndReturn(True) |
| 215 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 226 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 216 ['status'] + self.args, | 227 ['status'] + self.args, |
| 217 base_path, []).AndReturn(None) | 228 cwd=base_path, file_list=[], |
| 229 stdout=options.stdout).AndReturn(None) |
| 218 | 230 |
| 219 self.mox.ReplayAll() | 231 self.mox.ReplayAll() |
| 220 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 232 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 221 relpath=self.relpath) | 233 relpath=self.relpath) |
| 222 file_list = [] | 234 file_list = [] |
| 223 self.assertEqual(scm.status(options, self.args, file_list), None) | 235 self.assertEqual(scm.status(options, self.args, file_list), None) |
| 224 | 236 |
| 225 | 237 |
| 226 # TODO(maruel): TEST REVISIONS!!! | 238 # TODO(maruel): TEST REVISIONS!!! |
| 227 # TODO(maruel): TEST RELOCATE!!! | 239 # TODO(maruel): TEST RELOCATE!!! |
| 228 def testUpdateCheckout(self): | 240 def testUpdateCheckout(self): |
| 229 options = self.Options(verbose=True) | 241 options = self.Options(verbose=True) |
| 230 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 242 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 231 file_info = gclient_scm.gclient_utils.PrintableObject() | 243 file_info = gclient_scm.gclient_utils.PrintableObject() |
| 232 file_info.root = 'blah' | 244 file_info.root = 'blah' |
| 233 file_info.url = self.url | 245 file_info.url = self.url |
| 234 file_info.uuid = 'ABC' | 246 file_info.uuid = 'ABC' |
| 235 file_info.revision = 42 | 247 file_info.revision = 42 |
| 236 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 248 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 237 ).AndReturn(False) | 249 ).AndReturn(False) |
| 238 # Checkout. | 250 # Checkout. |
| 239 gclient_scm.os.path.exists(base_path).AndReturn(False) | 251 gclient_scm.os.path.exists(base_path).AndReturn(False) |
| 240 files_list = self.mox.CreateMockAnything() | 252 files_list = self.mox.CreateMockAnything() |
| 253 gclient_scm.scm.SVN.Capture(['--version'] |
| 254 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 241 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, | 255 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, |
| 242 ['checkout', self.url, base_path, | 256 ['checkout', self.url, base_path, |
| 243 '--force'], | 257 '--force'], |
| 244 self.root_dir, files_list) | 258 cwd=self.root_dir, |
| 259 file_list=files_list, |
| 260 stdout=options.stdout) |
| 245 self.mox.ReplayAll() | 261 self.mox.ReplayAll() |
| 246 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 262 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 247 relpath=self.relpath) | 263 relpath=self.relpath) |
| 248 scm.update(options, (), files_list) | 264 scm.update(options, (), files_list) |
| 249 | 265 |
| 250 def testUpdateUpdate(self): | 266 def testUpdateUpdate(self): |
| 251 options = self.Options(verbose=True) | 267 options = self.Options(verbose=True) |
| 252 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 268 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 253 options.force = True | 269 options.force = True |
| 254 options.nohooks = False | 270 options.nohooks = False |
| (...skipping 13 matching lines...) Expand all Loading... |
| 268 # Checkout or update. | 284 # Checkout or update. |
| 269 gclient_scm.os.path.exists(base_path).AndReturn(True) | 285 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 270 gclient_scm.scm.SVN.CaptureInfo( | 286 gclient_scm.scm.SVN.CaptureInfo( |
| 271 gclient_scm.os.path.join(base_path, "."), '.' | 287 gclient_scm.os.path.join(base_path, "."), '.' |
| 272 ).AndReturn(file_info) | 288 ).AndReturn(file_info) |
| 273 # Cheat a bit here. | 289 # Cheat a bit here. |
| 274 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 290 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 275 additional_args = [] | 291 additional_args = [] |
| 276 if options.manually_grab_svn_rev: | 292 if options.manually_grab_svn_rev: |
| 277 additional_args = ['--revision', str(file_info['Revision'])] | 293 additional_args = ['--revision', str(file_info['Revision'])] |
| 278 if options.force and gclient_scm.scm.SVN.AssertVersion("1.5")[0]: | 294 gclient_scm.scm.SVN.Capture(['--version'] |
| 279 additional_args.append('--force') | 295 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 296 additional_args.append('--force') |
| 280 files_list = [] | 297 files_list = [] |
| 281 gclient_scm.scm.SVN.RunAndGetFileList( | 298 gclient_scm.scm.SVN.RunAndGetFileList( |
| 282 options.verbose, | 299 options.verbose, |
| 283 ['update', base_path] + additional_args, | 300 ['update', base_path] + additional_args, |
| 284 self.root_dir, files_list) | 301 cwd=self.root_dir, file_list=files_list, stdout=options.stdout) |
| 285 | 302 |
| 286 self.mox.ReplayAll() | 303 self.mox.ReplayAll() |
| 287 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 304 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 288 relpath=self.relpath) | 305 relpath=self.relpath) |
| 289 scm.update(options, (), files_list) | 306 scm.update(options, (), files_list) |
| 290 | 307 |
| 291 def testUpdateSingleCheckout(self): | 308 def testUpdateSingleCheckout(self): |
| 292 options = self.Options(verbose=True) | 309 options = self.Options(verbose=True) |
| 293 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 310 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 294 file_info = { | 311 file_info = { |
| 295 'URL': self.url, | 312 'URL': self.url, |
| 296 'Revision': 42, | 313 'Revision': 42, |
| 297 } | 314 } |
| 298 | 315 |
| 299 # Checks to make sure that we support svn co --depth. | 316 # Checks to make sure that we support svn co --depth. |
| 300 gclient_scm.scm.SVN.current_version = None | 317 gclient_scm.scm.SVN.current_version = None |
| 301 gclient_scm.scm.SVN.Capture(['--version'] | 318 gclient_scm.scm.SVN.Capture(['--version'] |
| 302 ).AndReturn('svn, version 1.5.1 (r32289)') | 319 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 303 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') | 320 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 304 ).AndReturn(False) | 321 ).AndReturn(False) |
| 305 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') | 322 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 306 ).AndReturn(False) | 323 ).AndReturn(False) |
| 307 | 324 |
| 308 # Verify no locked files. | 325 # Verify no locked files. |
| 309 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') | 326 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 310 ).AndReturn([]) | 327 ).AndReturn([]) |
| 311 | 328 |
| 312 # When checking out a single file, we issue an svn checkout and svn update. | 329 # When checking out a single file, we issue an svn checkout and svn update. |
| 313 files_list = self.mox.CreateMockAnything() | 330 files_list = self.mox.CreateMockAnything() |
| 314 gclient_scm.scm.SVN.Run( | 331 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 315 ['checkout', '--depth', 'empty', self.url, base_path], | 332 ['svn', 'checkout', '--depth', 'empty', self.url, base_path], |
| 316 cwd=self.root_dir) | 333 always=True, cwd=self.root_dir, stdout=options.stdout) |
| 317 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], | 334 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], |
| 318 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) | 335 cwd=base_path, file_list=files_list, stdout=options.stdout) |
| 319 | 336 |
| 320 # Now we fall back on scm.update(). | 337 # Now we fall back on scm.update(). |
| 321 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 338 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 322 ).AndReturn(False) | 339 ).AndReturn(False) |
| 323 gclient_scm.os.path.exists(base_path).AndReturn(True) | 340 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 324 gclient_scm.scm.SVN.CaptureInfo( | 341 gclient_scm.scm.SVN.CaptureInfo( |
| 325 gclient_scm.os.path.join(base_path, "."), '.' | 342 gclient_scm.os.path.join(base_path, "."), '.' |
| 326 ).AndReturn(file_info) | 343 ).AndReturn(file_info) |
| 327 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 344 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 328 print("\n_____ %s at 42" % self.relpath) | 345 options.stdout.write("\n_____ %s at 42" % self.relpath) |
| 346 options.stdout.write('\n') |
| 329 | 347 |
| 330 self.mox.ReplayAll() | 348 self.mox.ReplayAll() |
| 331 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 349 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 332 relpath=self.relpath) | 350 relpath=self.relpath) |
| 333 scm.updatesingle(options, ['DEPS'], files_list) | 351 scm.updatesingle(options, ['DEPS'], files_list) |
| 334 | 352 |
| 335 def testUpdateSingleCheckoutSVN14(self): | 353 def testUpdateSingleCheckoutSVN14(self): |
| 336 options = self.Options(verbose=True) | 354 options = self.Options(verbose=True) |
| 337 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 355 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 338 file_info = { | 356 file_info = { |
| 339 'URL': self.url, | 357 'URL': self.url, |
| 340 'Revision': 42, | 358 'Revision': 42, |
| 341 } | 359 } |
| 342 | 360 |
| 343 # Checks to make sure that we support svn co --depth. | 361 # Checks to make sure that we support svn co --depth. |
| 344 gclient_scm.scm.SVN.current_version = None | 362 gclient_scm.scm.SVN.current_version = None |
| 345 gclient_scm.scm.SVN.Capture(['--version'] | 363 gclient_scm.scm.SVN.Capture(['--version'] |
| 346 ).AndReturn('svn, version 1.4.4 (r25188)') | 364 ).AndReturn('svn, version 1.4.4 (r25188)') |
| 347 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path) | 365 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path) |
| 348 ).AndReturn(True) | 366 ).AndReturn(True) |
| 349 | 367 |
| 350 # When checking out a single file with svn 1.4, we use svn export | 368 # When checking out a single file with svn 1.4, we use svn export |
| 351 files_list = self.mox.CreateMockAnything() | 369 files_list = self.mox.CreateMockAnything() |
| 352 gclient_scm.scm.SVN.Run( | 370 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 353 ['export', gclient_scm.os.path.join(self.url, 'DEPS'), | 371 ['svn', 'export', gclient_scm.os.path.join(self.url, 'DEPS'), |
| 354 gclient_scm.os.path.join(base_path, 'DEPS')], | 372 gclient_scm.os.path.join(base_path, 'DEPS')], |
| 355 cwd=self.root_dir) | 373 always=True, cwd=self.root_dir, stdout=options.stdout) |
| 356 | 374 |
| 357 self.mox.ReplayAll() | 375 self.mox.ReplayAll() |
| 358 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 376 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 359 relpath=self.relpath) | 377 relpath=self.relpath) |
| 360 scm.updatesingle(options, ['DEPS'], files_list) | 378 scm.updatesingle(options, ['DEPS'], files_list) |
| 361 | 379 |
| 362 def testUpdateSingleCheckoutSVNUpgrade(self): | 380 def testUpdateSingleCheckoutSVNUpgrade(self): |
| 363 options = self.Options(verbose=True) | 381 options = self.Options(verbose=True) |
| 364 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 382 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 365 file_info = { | 383 file_info = { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 378 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') | 396 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 379 ).AndReturn(True) | 397 ).AndReturn(True) |
| 380 gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) | 398 gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) |
| 381 | 399 |
| 382 # Verify no locked files. | 400 # Verify no locked files. |
| 383 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') | 401 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 384 ).AndReturn([]) | 402 ).AndReturn([]) |
| 385 | 403 |
| 386 # When checking out a single file, we issue an svn checkout and svn update. | 404 # When checking out a single file, we issue an svn checkout and svn update. |
| 387 files_list = self.mox.CreateMockAnything() | 405 files_list = self.mox.CreateMockAnything() |
| 388 gclient_scm.scm.SVN.Run( | 406 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 389 ['checkout', '--depth', 'empty', self.url, base_path], | 407 ['svn', 'checkout', '--depth', 'empty', self.url, base_path], |
| 390 cwd=self.root_dir) | 408 always=True, cwd=self.root_dir, stdout=options.stdout) |
| 391 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], | 409 gclient_scm.scm.SVN.RunAndGetFileList(options.verbose, ['update', 'DEPS'], |
| 392 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) | 410 cwd=base_path, file_list=files_list, stdout=options.stdout) |
| 393 | 411 |
| 394 # Now we fall back on scm.update(). | 412 # Now we fall back on scm.update(). |
| 395 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 413 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 396 ).AndReturn(False) | 414 ).AndReturn(False) |
| 397 gclient_scm.os.path.exists(base_path).AndReturn(True) | 415 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 398 gclient_scm.scm.SVN.CaptureInfo( | 416 gclient_scm.scm.SVN.CaptureInfo( |
| 399 gclient_scm.os.path.join(base_path, "."), '.' | 417 gclient_scm.os.path.join(base_path, "."), '.' |
| 400 ).AndReturn(file_info) | 418 ).AndReturn(file_info) |
| 401 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 419 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 402 print("\n_____ %s at 42" % self.relpath) | 420 print("\n_____ %s at 42" % self.relpath) |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 relpath=self.relpath) | 778 relpath=self.relpath) |
| 761 rev_info = scm.revinfo(options, (), None) | 779 rev_info = scm.revinfo(options, (), None) |
| 762 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 780 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 763 | 781 |
| 764 | 782 |
| 765 if __name__ == '__main__': | 783 if __name__ == '__main__': |
| 766 import unittest | 784 import unittest |
| 767 unittest.main() | 785 unittest.main() |
| 768 | 786 |
| 769 # vim: ts=2:sw=2:tw=80:et: | 787 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |