Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: tests/gclient_scm_test.py

Issue 8771042: Enforces using cwd in all svn calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 'update', options, self.args) 149 'update', options, self.args)
150 150
151 def testRunCommandUnknown(self): 151 def testRunCommandUnknown(self):
152 # TODO(maruel): if ever used. 152 # TODO(maruel): if ever used.
153 pass 153 pass
154 154
155 def testRevertMissing(self): 155 def testRevertMissing(self):
156 options = self.Options(verbose=True) 156 options = self.Options(verbose=True)
157 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) 157 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
158 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 158 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
159 gclient_scm.scm.SVN.Capture(['--version'] 159 gclient_scm.scm.SVN.Capture(['--version'], None
160 ).AndReturn('svn, version 1.5.1 (r32289)') 160 ).AndReturn('svn, version 1.5.1 (r32289)')
161 # It'll to a checkout instead. 161 # It'll to a checkout instead.
162 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 162 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
163 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 163 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
164 # Checkout. 164 # Checkout.
165 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 165 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
166 parent = gclient_scm.os.path.dirname(self.base_path) 166 parent = gclient_scm.os.path.dirname(self.base_path)
167 gclient_scm.os.path.exists(parent).AndReturn(False) 167 gclient_scm.os.path.exists(parent).AndReturn(False)
168 gclient_scm.os.makedirs(parent) 168 gclient_scm.os.makedirs(parent)
169 gclient_scm.os.path.exists(parent).AndReturn(True) 169 gclient_scm.os.path.exists(parent).AndReturn(True)
(...skipping 20 matching lines...) Expand all
190 # Checkout. 190 # Checkout.
191 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 191 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
192 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 192 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
193 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 193 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
194 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 194 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
195 parent = gclient_scm.os.path.dirname(self.base_path) 195 parent = gclient_scm.os.path.dirname(self.base_path)
196 gclient_scm.os.path.exists(parent).AndReturn(False) 196 gclient_scm.os.path.exists(parent).AndReturn(False)
197 gclient_scm.os.makedirs(parent) 197 gclient_scm.os.makedirs(parent)
198 gclient_scm.os.path.exists(parent).AndReturn(True) 198 gclient_scm.os.path.exists(parent).AndReturn(True)
199 files_list = self.mox.CreateMockAnything() 199 files_list = self.mox.CreateMockAnything()
200 gclient_scm.scm.SVN.Capture(['--version']).AndReturn('svn, version 1.6') 200 gclient_scm.scm.SVN.Capture(['--version'], None
201 ).AndReturn('svn, version 1.6')
201 gclient_scm.scm.SVN.RunAndGetFileList( 202 gclient_scm.scm.SVN.RunAndGetFileList(
202 options.verbose, 203 options.verbose,
203 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], 204 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
204 cwd=self.root_dir, 205 cwd=self.root_dir,
205 file_list=files_list) 206 file_list=files_list)
206 207
207 self.mox.ReplayAll() 208 self.mox.ReplayAll()
208 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 209 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
209 relpath=self.relpath) 210 relpath=self.relpath)
210 scm.revert(options, self.args, files_list) 211 scm.revert(options, self.args, files_list)
211 self.checkstdout( 212 self.checkstdout(
212 '\n_____ %s is not a valid svn checkout, synching instead\n' % 213 '\n_____ %s is not a valid svn checkout, synching instead\n' %
213 self.relpath) 214 self.relpath)
214 215
215 def testRevertNone(self): 216 def testRevertNone(self):
216 options = self.Options(verbose=True) 217 options = self.Options(verbose=True)
217 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 218 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
218 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) 219 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
219 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([]) 220 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn([])
220 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 221 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
221 gclient_scm.scm.SVN.RunAndGetFileList( 222 gclient_scm.scm.SVN.RunAndGetFileList(
222 options.verbose, 223 options.verbose,
223 ['update', '--revision', 'BASE', '--ignore-externals'], 224 ['update', '--revision', 'BASE', '--ignore-externals'],
224 cwd=self.base_path, 225 cwd=self.base_path,
225 file_list=mox.IgnoreArg()) 226 file_list=mox.IgnoreArg())
226 227
227 self.mox.ReplayAll() 228 self.mox.ReplayAll()
228 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 229 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
229 relpath=self.relpath) 230 relpath=self.relpath)
230 file_list = [] 231 file_list = []
231 scm.revert(options, self.args, file_list) 232 scm.revert(options, self.args, file_list)
232 233
233 def testRevertDirectory(self): 234 def testRevertDirectory(self):
234 options = self.Options(verbose=True) 235 options = self.Options(verbose=True)
235 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 236 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
236 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) 237 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
237 items = [ 238 items = [
238 ('~ ', 'a'), 239 ('~ ', 'a'),
239 ] 240 ]
240 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) 241 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items)
241 file_path = join(self.base_path, 'a') 242 file_path = join(self.base_path, 'a')
242 gclient_scm.os.path.exists(file_path).AndReturn(True) 243 gclient_scm.os.path.exists(file_path).AndReturn(True)
243 gclient_scm.os.path.isfile(file_path).AndReturn(False) 244 gclient_scm.os.path.isfile(file_path).AndReturn(False)
244 gclient_scm.os.path.islink(file_path).AndReturn(False) 245 gclient_scm.os.path.islink(file_path).AndReturn(False)
245 gclient_scm.os.path.isdir(file_path).AndReturn(True) 246 gclient_scm.os.path.isdir(file_path).AndReturn(True)
246 gclient_scm.gclient_utils.RemoveDirectory(file_path) 247 gclient_scm.gclient_utils.RemoveDirectory(file_path)
247 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 248 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
248 gclient_scm.scm.SVN.RunAndGetFileList( 249 gclient_scm.scm.SVN.RunAndGetFileList(
249 options.verbose, 250 options.verbose,
250 ['update', '--revision', 'BASE', '--ignore-externals'], 251 ['update', '--revision', 'BASE', '--ignore-externals'],
251 cwd=self.base_path, 252 cwd=self.base_path,
252 file_list=mox.IgnoreArg()) 253 file_list=mox.IgnoreArg())
253 254
254 self.mox.ReplayAll() 255 self.mox.ReplayAll()
255 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 256 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
256 relpath=self.relpath) 257 relpath=self.relpath)
257 file_list2 = [] 258 file_list2 = []
258 scm.revert(options, self.args, file_list2) 259 scm.revert(options, self.args, file_list2)
259 self.checkstdout(('%s\n' % file_path)) 260 self.checkstdout(('%s\n' % file_path))
260 261
261 def testRevertDot(self): 262 def testRevertDot(self):
262 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') 263 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update')
263 options = self.Options(verbose=True) 264 options = self.Options(verbose=True)
264 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 265 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
265 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) 266 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
266 items = [ 267 items = [
267 ('~ ', '.'), 268 ('~ ', '.'),
268 ] 269 ]
269 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) 270 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items)
270 file_path = join(self.base_path, '.') 271 file_path = join(self.base_path, '.')
271 gclient_scm.os.path.exists(file_path).AndReturn(True) 272 gclient_scm.os.path.exists(file_path).AndReturn(True)
272 gclient_scm.os.path.isfile(file_path).AndReturn(False) 273 gclient_scm.os.path.isfile(file_path).AndReturn(False)
273 gclient_scm.os.path.islink(file_path).AndReturn(False) 274 gclient_scm.os.path.islink(file_path).AndReturn(False)
274 gclient_scm.os.path.isdir(file_path).AndReturn(True) 275 gclient_scm.os.path.isdir(file_path).AndReturn(True)
275 gclient_scm.gclient_utils.RemoveDirectory(file_path) 276 gclient_scm.gclient_utils.RemoveDirectory(file_path)
276 # pylint: disable=E1120 277 # pylint: disable=E1120
277 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) 278 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
278 gclient_scm.SVNWrapper.update(options, [], ['.']) 279 gclient_scm.SVNWrapper.update(options, [], ['.'])
279 280
(...skipping 30 matching lines...) Expand all
310 file_info.revision = 42 311 file_info.revision = 42
311 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 312 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
312 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 313 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
313 # Checkout. 314 # Checkout.
314 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 315 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
315 parent = gclient_scm.os.path.dirname(self.base_path) 316 parent = gclient_scm.os.path.dirname(self.base_path)
316 gclient_scm.os.path.exists(parent).AndReturn(False) 317 gclient_scm.os.path.exists(parent).AndReturn(False)
317 gclient_scm.os.makedirs(parent) 318 gclient_scm.os.makedirs(parent)
318 gclient_scm.os.path.exists(parent).AndReturn(True) 319 gclient_scm.os.path.exists(parent).AndReturn(True)
319 files_list = self.mox.CreateMockAnything() 320 files_list = self.mox.CreateMockAnything()
320 gclient_scm.scm.SVN.Capture(['--version'] 321 gclient_scm.scm.SVN.Capture(['--version'], None
321 ).AndReturn('svn, version 1.5.1 (r32289)') 322 ).AndReturn('svn, version 1.5.1 (r32289)')
322 gclient_scm.scm.SVN.RunAndGetFileList( 323 gclient_scm.scm.SVN.RunAndGetFileList(
323 options.verbose, 324 options.verbose,
324 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], 325 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
325 cwd=self.root_dir, 326 cwd=self.root_dir,
326 file_list=files_list) 327 file_list=files_list)
327 self.mox.ReplayAll() 328 self.mox.ReplayAll()
328 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 329 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
329 relpath=self.relpath) 330 relpath=self.relpath)
330 scm.update(options, (), files_list) 331 scm.update(options, (), files_list)
331 332
332 def testUpdateUpdate(self): 333 def testUpdateUpdate(self):
333 options = self.Options(verbose=True) 334 options = self.Options(verbose=True)
334 options.force = True 335 options.force = True
335 options.nohooks = False 336 options.nohooks = False
336 file_info = { 337 file_info = {
337 'Repository Root': 'blah', 338 'Repository Root': 'blah',
338 'URL': self.url, 339 'URL': self.url,
339 'UUID': 'ABC', 340 'UUID': 'ABC',
340 'Revision': 42, 341 'Revision': 42,
341 } 342 }
342 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 343 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
343 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 344 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
344 345
345 # Verify no locked files. 346 # Verify no locked files.
346 dotted_path = join(self.base_path, '.') 347 dotted_path = join(self.base_path, '.')
347 gclient_scm.scm.SVN.CaptureStatus(dotted_path).AndReturn([]) 348 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([])
348 349
349 # Checkout or update. 350 # Checkout or update.
350 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 351 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
351 gclient_scm.scm.SVN.CaptureInfo(dotted_path).AndReturn(file_info) 352 gclient_scm.scm.SVN.CaptureInfo(None, dotted_path).AndReturn(file_info)
352 # Cheat a bit here. 353 # Cheat a bit here.
353 gclient_scm.scm.SVN.CaptureInfo(file_info['URL']).AndReturn(file_info) 354 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], None).AndReturn(file_info)
354 additional_args = [] 355 additional_args = []
355 if options.manually_grab_svn_rev: 356 if options.manually_grab_svn_rev:
356 additional_args = ['--revision', str(file_info['Revision'])] 357 additional_args = ['--revision', str(file_info['Revision'])]
357 gclient_scm.scm.SVN.Capture(['--version'] 358 gclient_scm.scm.SVN.Capture(['--version'], None
358 ).AndReturn('svn, version 1.5.1 (r32289)') 359 ).AndReturn('svn, version 1.5.1 (r32289)')
359 additional_args.extend(['--force', '--ignore-externals']) 360 additional_args.extend(['--force', '--ignore-externals'])
360 files_list = [] 361 files_list = []
361 gclient_scm.scm.SVN.RunAndGetFileList( 362 gclient_scm.scm.SVN.RunAndGetFileList(
362 options.verbose, 363 options.verbose,
363 ['update', self.base_path] + additional_args, 364 ['update', self.base_path] + additional_args,
364 cwd=self.root_dir, file_list=files_list) 365 cwd=self.root_dir, file_list=files_list)
365 366
366 self.mox.ReplayAll() 367 self.mox.ReplayAll()
367 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 368 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
368 relpath=self.relpath) 369 relpath=self.relpath)
369 scm.update(options, (), files_list) 370 scm.update(options, (), files_list)
370 371
371 def testUpdateSingleCheckout(self): 372 def testUpdateSingleCheckout(self):
372 options = self.Options(verbose=True) 373 options = self.Options(verbose=True)
373 file_info = { 374 file_info = {
374 'URL': self.url, 375 'URL': self.url,
375 'Revision': 42, 376 'Revision': 42,
376 } 377 }
377 378
378 # Checks to make sure that we support svn co --depth. 379 # Checks to make sure that we support svn co --depth.
379 gclient_scm.scm.SVN.current_version = None 380 gclient_scm.scm.SVN.current_version = None
380 gclient_scm.scm.SVN.Capture(['--version'] 381 gclient_scm.scm.SVN.Capture(['--version'], None
381 ).AndReturn('svn, version 1.5.1 (r32289)') 382 ).AndReturn('svn, version 1.5.1 (r32289)')
382 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) 383 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False)
383 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(False) 384 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(False)
384 385
385 # Verify no locked files. 386 # Verify no locked files.
386 dotted_path = join(self.base_path, '.') 387 dotted_path = join(self.base_path, '.')
387 gclient_scm.scm.SVN.CaptureStatus(dotted_path).AndReturn([]) 388 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([])
388 389
389 # When checking out a single file, we issue an svn checkout and svn update. 390 # When checking out a single file, we issue an svn checkout and svn update.
390 files_list = self.mox.CreateMockAnything() 391 files_list = self.mox.CreateMockAnything()
391 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( 392 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader(
392 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], 393 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path],
393 always=True, 394 always=True,
394 cwd=self.root_dir) 395 cwd=self.root_dir)
395 gclient_scm.scm.SVN.RunAndGetFileList( 396 gclient_scm.scm.SVN.RunAndGetFileList(
396 options.verbose, 397 options.verbose,
397 ['update', 'DEPS', '--ignore-externals'], 398 ['update', 'DEPS', '--ignore-externals'],
398 cwd=self.base_path, 399 cwd=self.base_path,
399 file_list=files_list) 400 file_list=files_list)
400 401
401 # Now we fall back on scm.update(). 402 # Now we fall back on scm.update().
402 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 403 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
403 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 404 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
404 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 405 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
405 gclient_scm.scm.SVN.CaptureInfo(dotted_path).AndReturn(file_info) 406 gclient_scm.scm.SVN.CaptureInfo(None, dotted_path).AndReturn(file_info)
406 gclient_scm.scm.SVN.CaptureInfo(file_info['URL']).AndReturn(file_info) 407 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], None).AndReturn(file_info)
407 408
408 self.mox.ReplayAll() 409 self.mox.ReplayAll()
409 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 410 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
410 relpath=self.relpath) 411 relpath=self.relpath)
411 scm.updatesingle(options, ['DEPS'], files_list) 412 scm.updatesingle(options, ['DEPS'], files_list)
412 self.checkstdout('\n_____ %s at 42\n' % self.relpath) 413 self.checkstdout('\n_____ %s at 42\n' % self.relpath)
413 414
414 def testUpdateSingleCheckoutSVN14(self): 415 def testUpdateSingleCheckoutSVN14(self):
415 options = self.Options(verbose=True) 416 options = self.Options(verbose=True)
416 417
417 # Checks to make sure that we support svn co --depth. 418 # Checks to make sure that we support svn co --depth.
418 gclient_scm.scm.SVN.current_version = None 419 gclient_scm.scm.SVN.current_version = None
419 gclient_scm.scm.SVN.Capture(['--version'] 420 gclient_scm.scm.SVN.Capture(['--version'], None
420 ).AndReturn('svn, version 1.4.4 (r25188)') 421 ).AndReturn('svn, version 1.4.4 (r25188)')
421 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 422 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
422 423
423 # When checking out a single file with svn 1.4, we use svn export 424 # When checking out a single file with svn 1.4, we use svn export
424 files_list = self.mox.CreateMockAnything() 425 files_list = self.mox.CreateMockAnything()
425 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( 426 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader(
426 ['svn', 'export', join(self.url, 'DEPS'), join(self.base_path, 'DEPS')], 427 ['svn', 'export', join(self.url, 'DEPS'), join(self.base_path, 'DEPS')],
427 always=True, cwd=self.root_dir) 428 always=True, cwd=self.root_dir)
428 429
429 self.mox.ReplayAll() 430 self.mox.ReplayAll()
430 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 431 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
431 relpath=self.relpath) 432 relpath=self.relpath)
432 scm.updatesingle(options, ['DEPS'], files_list) 433 scm.updatesingle(options, ['DEPS'], files_list)
433 434
434 def testUpdateSingleCheckoutSVNUpgrade(self): 435 def testUpdateSingleCheckoutSVNUpgrade(self):
435 options = self.Options(verbose=True) 436 options = self.Options(verbose=True)
436 file_info = { 437 file_info = {
437 'URL': self.url, 438 'URL': self.url,
438 'Revision': 42, 439 'Revision': 42,
439 } 440 }
440 441
441 # Checks to make sure that we support svn co --depth. 442 # Checks to make sure that we support svn co --depth.
442 gclient_scm.scm.SVN.current_version = None 443 gclient_scm.scm.SVN.current_version = None
443 gclient_scm.scm.SVN.Capture(['--version'] 444 gclient_scm.scm.SVN.Capture(['--version'], None
444 ).AndReturn('svn, version 1.5.1 (r32289)') 445 ).AndReturn('svn, version 1.5.1 (r32289)')
445 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) 446 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False)
446 # If DEPS already exists, assume we're upgrading from svn1.4, so delete 447 # If DEPS already exists, assume we're upgrading from svn1.4, so delete
447 # the old DEPS file. 448 # the old DEPS file.
448 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(True) 449 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(True)
449 gclient_scm.os.remove(join(self.base_path, 'DEPS')) 450 gclient_scm.os.remove(join(self.base_path, 'DEPS'))
450 451
451 # Verify no locked files. 452 # Verify no locked files.
452 gclient_scm.scm.SVN.CaptureStatus(join(self.base_path, '.')).AndReturn([]) 453 gclient_scm.scm.SVN.CaptureStatus(
454 None, join(self.base_path, '.')).AndReturn([])
453 455
454 # When checking out a single file, we issue an svn checkout and svn update. 456 # When checking out a single file, we issue an svn checkout and svn update.
455 files_list = self.mox.CreateMockAnything() 457 files_list = self.mox.CreateMockAnything()
456 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( 458 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader(
457 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], 459 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path],
458 always=True, 460 always=True,
459 cwd=self.root_dir) 461 cwd=self.root_dir)
460 gclient_scm.scm.SVN.RunAndGetFileList( 462 gclient_scm.scm.SVN.RunAndGetFileList(
461 options.verbose, 463 options.verbose,
462 ['update', 'DEPS', '--ignore-externals'], 464 ['update', 'DEPS', '--ignore-externals'],
463 cwd=self.base_path, 465 cwd=self.base_path,
464 file_list=files_list) 466 file_list=files_list)
465 467
466 # Now we fall back on scm.update(). 468 # Now we fall back on scm.update().
467 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 469 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
468 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 470 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
469 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 471 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
470 gclient_scm.scm.SVN.CaptureInfo( 472 gclient_scm.scm.SVN.CaptureInfo(
471 join(self.base_path, ".")).AndReturn(file_info) 473 None, join(self.base_path, ".")).AndReturn(file_info)
472 gclient_scm.scm.SVN.CaptureInfo(file_info['URL']).AndReturn(file_info) 474 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], None).AndReturn(file_info)
473 475
474 self.mox.ReplayAll() 476 self.mox.ReplayAll()
475 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 477 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
476 relpath=self.relpath) 478 relpath=self.relpath)
477 scm.updatesingle(options, ['DEPS'], files_list) 479 scm.updatesingle(options, ['DEPS'], files_list)
478 self.checkstdout( 480 self.checkstdout(
479 ('\n_____ %s at 42\n' % self.relpath)) 481 ('\n_____ %s at 42\n' % self.relpath))
480 482
481 def testUpdateSingleUpdate(self): 483 def testUpdateSingleUpdate(self):
482 options = self.Options(verbose=True) 484 options = self.Options(verbose=True)
483 file_info = { 485 file_info = {
484 'URL': self.url, 486 'URL': self.url,
485 'Revision': 42, 487 'Revision': 42,
486 } 488 }
487 # Checks to make sure that we support svn co --depth. 489 # Checks to make sure that we support svn co --depth.
488 gclient_scm.scm.SVN.current_version = None 490 gclient_scm.scm.SVN.current_version = None
489 gclient_scm.scm.SVN.Capture(['--version'] 491 gclient_scm.scm.SVN.Capture(['--version'], None
490 ).AndReturn('svn, version 1.5.1 (r32289)') 492 ).AndReturn('svn, version 1.5.1 (r32289)')
491 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) 493 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True)
492 494
493 # Verify no locked files. 495 # Verify no locked files.
494 gclient_scm.scm.SVN.CaptureStatus(join(self.base_path, '.')).AndReturn([]) 496 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.')
497 ).AndReturn([])
495 498
496 # Now we fall back on scm.update(). 499 # Now we fall back on scm.update().
497 files_list = self.mox.CreateMockAnything() 500 files_list = self.mox.CreateMockAnything()
498 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) 501 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
499 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 502 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
500 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 503 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
501 gclient_scm.scm.SVN.CaptureInfo( 504 gclient_scm.scm.SVN.CaptureInfo(
502 join(self.base_path, '.')).AndReturn(file_info) 505 None, join(self.base_path, '.')).AndReturn(file_info)
503 gclient_scm.scm.SVN.CaptureInfo(file_info['URL']).AndReturn(file_info) 506 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], None).AndReturn(file_info)
504 507
505 self.mox.ReplayAll() 508 self.mox.ReplayAll()
506 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 509 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
507 relpath=self.relpath) 510 relpath=self.relpath)
508 scm.updatesingle(options, ['DEPS'], files_list) 511 scm.updatesingle(options, ['DEPS'], files_list)
509 self.checkstdout('\n_____ %s at 42\n' % self.relpath) 512 self.checkstdout('\n_____ %s at 42\n' % self.relpath)
510 513
511 def testUpdateGit(self): 514 def testUpdateGit(self):
512 options = self.Options(verbose=True) 515 options = self.Options(verbose=True)
513 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') 516 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 985
983 if __name__ == '__main__': 986 if __name__ == '__main__':
984 if '-v' in sys.argv: 987 if '-v' in sys.argv:
985 logging.basicConfig( 988 logging.basicConfig(
986 level=logging.DEBUG, 989 level=logging.DEBUG,
987 format='%(asctime).19s %(levelname)s %(filename)s:' 990 format='%(asctime).19s %(levelname)s %(filename)s:'
988 '%(lineno)s %(message)s') 991 '%(lineno)s %(message)s')
989 unittest.main() 992 unittest.main()
990 993
991 # vim: ts=2:sw=2:tw=80:et: 994 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« gclient_scm.py ('K') | « testing_support/fake_repos.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698