| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. | 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') | 260 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') |
| 261 gclient_scm.os.path.exists(file_path).AndReturn(True) | 261 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 262 print("________ found .git directory; skipping %s" % self.relpath) | 262 print("________ found .git directory; skipping %s" % self.relpath) |
| 263 | 263 |
| 264 self.mox.ReplayAll() | 264 self.mox.ReplayAll() |
| 265 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 265 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 266 relpath=self.relpath) | 266 relpath=self.relpath) |
| 267 file_list = [] | 267 file_list = [] |
| 268 scm.update(options, self.args, file_list) | 268 scm.update(options, self.args, file_list) |
| 269 | 269 |
| 270 def testGetSVNFileInfo(self): | |
| 271 xml_text = r"""<?xml version="1.0"?> | |
| 272 <info> | |
| 273 <entry kind="file" path="%s" revision="14628"> | |
| 274 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> | |
| 275 <repository><root>http://src.chromium.org/svn</root></repository> | |
| 276 <wc-info> | |
| 277 <schedule>add</schedule> | |
| 278 <depth>infinity</depth> | |
| 279 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from-
url> | |
| 280 <copy-from-rev>14628</copy-from-rev> | |
| 281 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> | |
| 282 </wc-info> | |
| 283 </entry> | |
| 284 </info> | |
| 285 """ % self.url | |
| 286 gclient_scm.CaptureSVN(['info', '--xml', self.url], | |
| 287 '.', True).AndReturn(xml_text) | |
| 288 expected = { | |
| 289 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', | |
| 290 'UUID': None, | |
| 291 'Repository Root': 'http://src.chromium.org/svn', | |
| 292 'Schedule': 'add', | |
| 293 'Copied From URL': | |
| 294 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS', | |
| 295 'Copied From Rev': '14628', | |
| 296 'Path': self.url, | |
| 297 'Revision': 14628, | |
| 298 'Node Kind': 'file', | |
| 299 } | |
| 300 self.mox.ReplayAll() | |
| 301 file_info = self._CaptureSVNInfo(self.url, '.', True) | |
| 302 self.assertEquals(sorted(file_info.items()), sorted(expected.items())) | |
| 303 | |
| 304 def testCaptureSvnInfo(self): | |
| 305 xml_text = """<?xml version="1.0"?> | |
| 306 <info> | |
| 307 <entry | |
| 308 kind="dir" | |
| 309 path="." | |
| 310 revision="35"> | |
| 311 <url>%s</url> | |
| 312 <repository> | |
| 313 <root>%s</root> | |
| 314 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> | |
| 315 </repository> | |
| 316 <wc-info> | |
| 317 <schedule>normal</schedule> | |
| 318 <depth>infinity</depth> | |
| 319 </wc-info> | |
| 320 <commit | |
| 321 revision="35"> | |
| 322 <author>maruel</author> | |
| 323 <date>2008-12-04T20:12:19.685120Z</date> | |
| 324 </commit> | |
| 325 </entry> | |
| 326 </info> | |
| 327 """ % (self.url, self.root_dir) | |
| 328 gclient_scm.CaptureSVN(['info', '--xml', | |
| 329 self.url], '.', True).AndReturn(xml_text) | |
| 330 self.mox.ReplayAll() | |
| 331 file_info = self._CaptureSVNInfo(self.url, '.', True) | |
| 332 expected = { | |
| 333 'URL': self.url, | |
| 334 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', | |
| 335 'Revision': 35, | |
| 336 'Repository Root': self.root_dir, | |
| 337 'Schedule': 'normal', | |
| 338 'Copied From URL': None, | |
| 339 'Copied From Rev': None, | |
| 340 'Path': '.', | |
| 341 'Node Kind': 'dir', | |
| 342 } | |
| 343 self.assertEqual(file_info, expected) | |
| 344 | |
| 345 def testRevinfo(self): | |
| 346 options = self.Options(verbose=False) | |
| 347 xml_text = """<?xml version="1.0"?> | |
| 348 <info> | |
| 349 <entry | |
| 350 kind="dir" | |
| 351 path="." | |
| 352 revision="35"> | |
| 353 <url>%s</url> | |
| 354 <repository> | |
| 355 <root>%s</root> | |
| 356 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> | |
| 357 </repository> | |
| 358 <wc-info> | |
| 359 <schedule>normal</schedule> | |
| 360 <depth>infinity</depth> | |
| 361 </wc-info> | |
| 362 <commit | |
| 363 revision="35"> | |
| 364 <author>maruel</author> | |
| 365 <date>2008-12-04T20:12:19.685120Z</date> | |
| 366 </commit> | |
| 367 </entry> | |
| 368 </info> | |
| 369 """ % (self.url, self.root_dir) | |
| 370 gclient_scm.os.getcwd().AndReturn('bleh') | |
| 371 gclient_scm.CaptureSVN(['info', '--xml', self.url], 'bleh' | |
| 372 ).AndReturn(xml_text) | |
| 373 self.mox.ReplayAll() | |
| 374 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
| 375 relpath=self.relpath) | |
| 376 rev_info = scm.revinfo(options, self.args, None) | |
| 377 self.assertEqual(rev_info, '35') | |
| 378 | |
| 379 | 270 |
| 380 class GitWrapperTestCase(SuperMoxBaseTestBase): | 271 class GitWrapperTestCase(SuperMoxBaseTestBase): |
| 381 """This class doesn't use pymox.""" | 272 """This class doesn't use pymox.""" |
| 382 class OptionsObject(object): | 273 class OptionsObject(object): |
| 383 def __init__(self, test_case, verbose=False, revision=None): | 274 def __init__(self, test_case, verbose=False, revision=None): |
| 384 self.verbose = verbose | 275 self.verbose = verbose |
| 385 self.revision = revision | 276 self.revision = revision |
| 386 self.manually_grab_svn_rev = True | 277 self.manually_grab_svn_rev = True |
| 387 self.deps_os = None | 278 self.deps_os = None |
| 388 self.force = False | 279 self.force = False |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 M 100644 :4 a | 321 M 100644 :4 a |
| 431 M 100644 :5 b | 322 M 100644 :5 b |
| 432 | 323 |
| 433 reset refs/heads/master | 324 reset refs/heads/master |
| 434 from :3 | 325 from :3 |
| 435 """ | 326 """ |
| 436 def Options(self, *args, **kwargs): | 327 def Options(self, *args, **kwargs): |
| 437 return self.OptionsObject(self, *args, **kwargs) | 328 return self.OptionsObject(self, *args, **kwargs) |
| 438 | 329 |
| 439 def CreateGitRepo(self, git_import, path): | 330 def CreateGitRepo(self, git_import, path): |
| 331 """Do it for real.""" |
| 440 try: | 332 try: |
| 441 Popen(['git', 'init'], stdout=PIPE, stderr=STDOUT, | 333 Popen(['git', 'init'], stdout=PIPE, stderr=STDOUT, |
| 442 cwd=path).communicate() | 334 cwd=path).communicate() |
| 443 except OSError: | 335 except OSError: |
| 444 # git is not available, skip this test. | 336 # git is not available, skip this test. |
| 445 return False | 337 return False |
| 446 Popen(['git', 'fast-import'], stdin=PIPE, stdout=PIPE, stderr=STDOUT, | 338 Popen(['git', 'fast-import'], stdin=PIPE, stdout=PIPE, stderr=STDOUT, |
| 447 cwd=path).communicate(input=git_import) | 339 cwd=path).communicate(input=git_import) |
| 448 Popen(['git', 'checkout'], stdout=PIPE, stderr=STDOUT, | 340 Popen(['git', 'checkout'], stdout=PIPE, stderr=STDOUT, |
| 449 cwd=path).communicate() | 341 cwd=path).communicate() |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 def testRevinfo(self): | 497 def testRevinfo(self): |
| 606 if not self.enabled: | 498 if not self.enabled: |
| 607 return | 499 return |
| 608 options = self.Options() | 500 options = self.Options() |
| 609 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 501 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 610 relpath=self.relpath) | 502 relpath=self.relpath) |
| 611 rev_info = scm.revinfo(options, (), None) | 503 rev_info = scm.revinfo(options, (), None) |
| 612 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 504 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 613 | 505 |
| 614 | 506 |
| 615 class RunSVNTestCase(BaseTestCase): | |
| 616 def testRunSVN(self): | |
| 617 self.UnMock(gclient_scm, 'RunSVN') | |
| 618 param2 = 'bleh' | |
| 619 gclient_scm.gclient_utils.SubprocessCall(['svn', 'foo', 'bar'], | |
| 620 param2).AndReturn(None) | |
| 621 self.mox.ReplayAll() | |
| 622 gclient_scm.RunSVN(['foo', 'bar'], param2) | |
| 623 | |
| 624 | |
| 625 if __name__ == '__main__': | 507 if __name__ == '__main__': |
| 626 import unittest | 508 import unittest |
| 627 unittest.main() | 509 unittest.main() |
| 628 | 510 |
| 629 # vim: ts=2:sw=2:tw=80:et: | 511 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |