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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 relpath=self.relpath) | 267 relpath=self.relpath) |
268 scm.update(options, (), files_list) | 268 scm.update(options, (), files_list) |
269 | 269 |
270 def testUpdateSingleCheckout(self): | 270 def testUpdateSingleCheckout(self): |
271 options = self.Options(verbose=True) | 271 options = self.Options(verbose=True) |
272 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 272 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
273 file_info = { | 273 file_info = { |
274 'URL': self.url, | 274 'URL': self.url, |
275 'Revision': 42, | 275 'Revision': 42, |
276 } | 276 } |
| 277 |
| 278 # Checks to make sure that we support svn co --depth. |
| 279 gclient_scm.scm.SVN.current_version = None |
| 280 gclient_scm.scm.SVN.Capture(['--version'] |
| 281 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 282 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 283 ).AndReturn(False) |
| 284 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 285 ).AndReturn(False) |
| 286 |
277 # When checking out a single file, we issue an svn checkout and svn update. | 287 # When checking out a single file, we issue an svn checkout and svn update. |
278 gclient_scm.os.path.exists(base_path).AndReturn(False) | |
279 files_list = self.mox.CreateMockAnything() | 288 files_list = self.mox.CreateMockAnything() |
280 gclient_scm.scm.SVN.Run( | 289 gclient_scm.scm.SVN.Run( |
281 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) | 290 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) |
282 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], | 291 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], |
283 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) | 292 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) |
284 | 293 |
285 # Now we fall back on scm.update(). | 294 # Now we fall back on scm.update(). |
286 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 295 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
287 ).AndReturn(False) | 296 ).AndReturn(False) |
288 gclient_scm.os.path.exists(base_path).AndReturn(True) | 297 gclient_scm.os.path.exists(base_path).AndReturn(True) |
289 gclient_scm.scm.SVN.CaptureInfo( | 298 gclient_scm.scm.SVN.CaptureInfo( |
290 gclient_scm.os.path.join(base_path, "."), '.' | 299 gclient_scm.os.path.join(base_path, "."), '.' |
291 ).AndReturn(file_info) | 300 ).AndReturn(file_info) |
292 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 301 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
293 print("\n_____ %s at 42" % self.relpath) | 302 print("\n_____ %s at 42" % self.relpath) |
294 | 303 |
295 self.mox.ReplayAll() | 304 self.mox.ReplayAll() |
296 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 305 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
297 relpath=self.relpath) | 306 relpath=self.relpath) |
298 scm.updatesingle(options, ['DEPS'], files_list) | 307 scm.updatesingle(options, ['DEPS'], files_list) |
299 | 308 |
| 309 def testUpdateSingleCheckoutSVN14(self): |
| 310 options = self.Options(verbose=True) |
| 311 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 312 file_info = { |
| 313 'URL': self.url, |
| 314 'Revision': 42, |
| 315 } |
| 316 |
| 317 # Checks to make sure that we support svn co --depth. |
| 318 gclient_scm.scm.SVN.current_version = None |
| 319 gclient_scm.scm.SVN.Capture(['--version'] |
| 320 ).AndReturn('svn, version 1.4.4 (r25188)') |
| 321 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path) |
| 322 ).AndReturn(True) |
| 323 |
| 324 # When checking out a single file with svn 1.4, we use svn export |
| 325 files_list = self.mox.CreateMockAnything() |
| 326 gclient_scm.scm.SVN.Run( |
| 327 ['export', gclient_scm.os.path.join(self.url, 'DEPS'), |
| 328 gclient_scm.os.path.join(base_path, 'DEPS')], self.root_dir) |
| 329 |
| 330 self.mox.ReplayAll() |
| 331 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 332 relpath=self.relpath) |
| 333 scm.updatesingle(options, ['DEPS'], files_list) |
| 334 |
| 335 def testUpdateSingleCheckoutSVNUpgrade(self): |
| 336 options = self.Options(verbose=True) |
| 337 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
| 338 file_info = { |
| 339 'URL': self.url, |
| 340 'Revision': 42, |
| 341 } |
| 342 |
| 343 # Checks to make sure that we support svn co --depth. |
| 344 gclient_scm.scm.SVN.current_version = None |
| 345 gclient_scm.scm.SVN.Capture(['--version'] |
| 346 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 347 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 348 ).AndReturn(False) |
| 349 # If DEPS already exists, assume we're upgrading from svn1.4, so delete |
| 350 # the old DEPS file. |
| 351 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 352 ).AndReturn(True) |
| 353 gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) |
| 354 |
| 355 # When checking out a single file, we issue an svn checkout and svn update. |
| 356 files_list = self.mox.CreateMockAnything() |
| 357 gclient_scm.scm.SVN.Run( |
| 358 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) |
| 359 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], |
| 360 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) |
| 361 |
| 362 # Now we fall back on scm.update(). |
| 363 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 364 ).AndReturn(False) |
| 365 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 366 gclient_scm.scm.SVN.CaptureInfo( |
| 367 gclient_scm.os.path.join(base_path, "."), '.' |
| 368 ).AndReturn(file_info) |
| 369 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 370 print("\n_____ %s at 42" % self.relpath) |
| 371 |
| 372 self.mox.ReplayAll() |
| 373 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 374 relpath=self.relpath) |
| 375 scm.updatesingle(options, ['DEPS'], files_list) |
| 376 |
300 def testUpdateSingleUpdate(self): | 377 def testUpdateSingleUpdate(self): |
301 options = self.Options(verbose=True) | 378 options = self.Options(verbose=True) |
302 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) | 379 base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) |
303 file_info = { | 380 file_info = { |
304 'URL': self.url, | 381 'URL': self.url, |
305 'Revision': 42, | 382 'Revision': 42, |
306 } | 383 } |
307 gclient_scm.os.path.exists(base_path).AndReturn(True) | 384 # Checks to make sure that we support svn co --depth. |
| 385 gclient_scm.scm.SVN.current_version = None |
| 386 gclient_scm.scm.SVN.Capture(['--version'] |
| 387 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 388 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 389 ).AndReturn(True) |
308 | 390 |
309 # Now we fall back on scm.update(). | 391 # Now we fall back on scm.update(). |
310 files_list = self.mox.CreateMockAnything() | 392 files_list = self.mox.CreateMockAnything() |
311 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 393 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
312 ).AndReturn(False) | 394 ).AndReturn(False) |
313 gclient_scm.os.path.exists(base_path).AndReturn(True) | 395 gclient_scm.os.path.exists(base_path).AndReturn(True) |
314 gclient_scm.scm.SVN.CaptureInfo( | 396 gclient_scm.scm.SVN.CaptureInfo( |
315 gclient_scm.os.path.join(base_path, "."), '.' | 397 gclient_scm.os.path.join(base_path, "."), '.' |
316 ).AndReturn(file_info) | 398 ).AndReturn(file_info) |
317 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 399 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 relpath=self.relpath) | 718 relpath=self.relpath) |
637 rev_info = scm.revinfo(options, (), None) | 719 rev_info = scm.revinfo(options, (), None) |
638 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 720 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
639 | 721 |
640 | 722 |
641 if __name__ == '__main__': | 723 if __name__ == '__main__': |
642 import unittest | 724 import unittest |
643 unittest.main() | 725 unittest.main() |
644 | 726 |
645 # vim: ts=2:sw=2:tw=80:et: | 727 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |