| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 options.force = True | 248 options.force = True |
| 249 options.nohooks = False | 249 options.nohooks = False |
| 250 file_info = { | 250 file_info = { |
| 251 'Repository Root': 'blah', | 251 'Repository Root': 'blah', |
| 252 'URL': self.url, | 252 'URL': self.url, |
| 253 'UUID': 'ABC', | 253 'UUID': 'ABC', |
| 254 'Revision': 42, | 254 'Revision': 42, |
| 255 } | 255 } |
| 256 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 256 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 257 ).AndReturn(False) | 257 ).AndReturn(False) |
| 258 |
| 259 # Verify no locked files. |
| 260 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 261 ).AndReturn([]) |
| 262 |
| 258 # Checkout or update. | 263 # Checkout or update. |
| 259 gclient_scm.os.path.exists(base_path).AndReturn(True) | 264 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 260 gclient_scm.scm.SVN.CaptureInfo( | 265 gclient_scm.scm.SVN.CaptureInfo( |
| 261 gclient_scm.os.path.join(base_path, "."), '.' | 266 gclient_scm.os.path.join(base_path, "."), '.' |
| 262 ).AndReturn(file_info) | 267 ).AndReturn(file_info) |
| 263 # Cheat a bit here. | 268 # Cheat a bit here. |
| 264 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 269 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 265 additional_args = [] | 270 additional_args = [] |
| 266 if options.manually_grab_svn_rev: | 271 if options.manually_grab_svn_rev: |
| 267 additional_args = ['--revision', str(file_info['Revision'])] | 272 additional_args = ['--revision', str(file_info['Revision'])] |
| (...skipping 20 matching lines...) Expand all Loading... |
| 288 | 293 |
| 289 # Checks to make sure that we support svn co --depth. | 294 # Checks to make sure that we support svn co --depth. |
| 290 gclient_scm.scm.SVN.current_version = None | 295 gclient_scm.scm.SVN.current_version = None |
| 291 gclient_scm.scm.SVN.Capture(['--version'] | 296 gclient_scm.scm.SVN.Capture(['--version'] |
| 292 ).AndReturn('svn, version 1.5.1 (r32289)') | 297 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 293 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') | 298 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 294 ).AndReturn(False) | 299 ).AndReturn(False) |
| 295 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') | 300 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 296 ).AndReturn(False) | 301 ).AndReturn(False) |
| 297 | 302 |
| 303 # Verify no locked files. |
| 304 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 305 ).AndReturn([]) |
| 306 |
| 298 # When checking out a single file, we issue an svn checkout and svn update. | 307 # When checking out a single file, we issue an svn checkout and svn update. |
| 299 files_list = self.mox.CreateMockAnything() | 308 files_list = self.mox.CreateMockAnything() |
| 300 gclient_scm.scm.SVN.Run( | 309 gclient_scm.scm.SVN.Run( |
| 301 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) | 310 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) |
| 302 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], | 311 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], |
| 303 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) | 312 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) |
| 304 | 313 |
| 305 # Now we fall back on scm.update(). | 314 # Now we fall back on scm.update(). |
| 306 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 315 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 307 ).AndReturn(False) | 316 ).AndReturn(False) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 gclient_scm.scm.SVN.Capture(['--version'] | 365 gclient_scm.scm.SVN.Capture(['--version'] |
| 357 ).AndReturn('svn, version 1.5.1 (r32289)') | 366 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 358 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') | 367 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 359 ).AndReturn(False) | 368 ).AndReturn(False) |
| 360 # If DEPS already exists, assume we're upgrading from svn1.4, so delete | 369 # If DEPS already exists, assume we're upgrading from svn1.4, so delete |
| 361 # the old DEPS file. | 370 # the old DEPS file. |
| 362 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') | 371 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') |
| 363 ).AndReturn(True) | 372 ).AndReturn(True) |
| 364 gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) | 373 gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) |
| 365 | 374 |
| 375 # Verify no locked files. |
| 376 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 377 ).AndReturn([]) |
| 378 |
| 366 # When checking out a single file, we issue an svn checkout and svn update. | 379 # When checking out a single file, we issue an svn checkout and svn update. |
| 367 files_list = self.mox.CreateMockAnything() | 380 files_list = self.mox.CreateMockAnything() |
| 368 gclient_scm.scm.SVN.Run( | 381 gclient_scm.scm.SVN.Run( |
| 369 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) | 382 ['checkout', '--depth', 'empty', self.url, base_path], self.root_dir) |
| 370 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], | 383 gclient_scm.scm.SVN.RunAndGetFileList(options, ['update', 'DEPS'], |
| 371 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) | 384 gclient_scm.os.path.join(self.root_dir, self.relpath), files_list) |
| 372 | 385 |
| 373 # Now we fall back on scm.update(). | 386 # Now we fall back on scm.update(). |
| 374 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 387 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 375 ).AndReturn(False) | 388 ).AndReturn(False) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 392 'URL': self.url, | 405 'URL': self.url, |
| 393 'Revision': 42, | 406 'Revision': 42, |
| 394 } | 407 } |
| 395 # Checks to make sure that we support svn co --depth. | 408 # Checks to make sure that we support svn co --depth. |
| 396 gclient_scm.scm.SVN.current_version = None | 409 gclient_scm.scm.SVN.current_version = None |
| 397 gclient_scm.scm.SVN.Capture(['--version'] | 410 gclient_scm.scm.SVN.Capture(['--version'] |
| 398 ).AndReturn('svn, version 1.5.1 (r32289)') | 411 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 399 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') | 412 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') |
| 400 ).AndReturn(True) | 413 ).AndReturn(True) |
| 401 | 414 |
| 415 # Verify no locked files. |
| 416 gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') |
| 417 ).AndReturn([]) |
| 418 |
| 402 # Now we fall back on scm.update(). | 419 # Now we fall back on scm.update(). |
| 403 files_list = self.mox.CreateMockAnything() | 420 files_list = self.mox.CreateMockAnything() |
| 404 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') | 421 gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') |
| 405 ).AndReturn(False) | 422 ).AndReturn(False) |
| 406 gclient_scm.os.path.exists(base_path).AndReturn(True) | 423 gclient_scm.os.path.exists(base_path).AndReturn(True) |
| 407 gclient_scm.scm.SVN.CaptureInfo( | 424 gclient_scm.scm.SVN.CaptureInfo( |
| 408 gclient_scm.os.path.join(base_path, "."), '.' | 425 gclient_scm.os.path.join(base_path, "."), '.' |
| 409 ).AndReturn(file_info) | 426 ).AndReturn(file_info) |
| 410 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) | 427 gclient_scm.scm.SVN.CaptureInfo(file_info['URL'], '.').AndReturn(file_info) |
| 411 print("\n_____ %s at 42" % self.relpath) | 428 print("\n_____ %s at 42" % self.relpath) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 relpath=self.relpath) | 752 relpath=self.relpath) |
| 736 rev_info = scm.revinfo(options, (), None) | 753 rev_info = scm.revinfo(options, (), None) |
| 737 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 754 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 738 | 755 |
| 739 | 756 |
| 740 if __name__ == '__main__': | 757 if __name__ == '__main__': |
| 741 import unittest | 758 import unittest |
| 742 unittest.main() | 759 unittest.main() |
| 743 | 760 |
| 744 # vim: ts=2:sw=2:tw=80:et: | 761 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |