| 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 scm.py.""" | 6 """Unit tests for scm.py.""" |
| 7 | 7 |
| 8 from shutil import rmtree | 8 from shutil import rmtree |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 self.url = self.Url() | 154 self.url = self.Url() |
| 155 self.relpath = 'asf' | 155 self.relpath = 'asf' |
| 156 | 156 |
| 157 def testMembersChanged(self): | 157 def testMembersChanged(self): |
| 158 self.mox.ReplayAll() | 158 self.mox.ReplayAll() |
| 159 members = [ | 159 members = [ |
| 160 'AssertVersion', 'Capture', 'CaptureBaseRevision', | 160 'AssertVersion', 'Capture', 'CaptureBaseRevision', |
| 161 'CaptureHeadRevision', 'CaptureInfo', 'CaptureStatus', | 161 'CaptureHeadRevision', 'CaptureInfo', 'CaptureStatus', |
| 162 'current_version', 'DiffItem', 'GenerateDiff', | 162 'current_version', 'DiffItem', 'GenerateDiff', |
| 163 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', | 163 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved', |
| 164 'IsMovedInfo', 'ReadSimpleAuth', 'Run', 'RunAndGetFileList', | 164 'IsMovedInfo', 'ReadSimpleAuth', 'RunAndGetFileList', |
| 165 ] | 165 ] |
| 166 # If this test fails, you should add the relevant test. | 166 # If this test fails, you should add the relevant test. |
| 167 self.compareMembers(scm.SVN, members) | 167 self.compareMembers(scm.SVN, members) |
| 168 | 168 |
| 169 def testGetCheckoutRoot(self): | 169 def testGetCheckoutRoot(self): |
| 170 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') | 170 self.mox.StubOutWithMock(scm.SVN, 'CaptureInfo') |
| 171 self.mox.StubOutWithMock(scm, 'GetCasedPath') | 171 self.mox.StubOutWithMock(scm, 'GetCasedPath') |
| 172 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) | 172 scm.os.path.abspath(self.root_dir + 'x').AndReturn(self.root_dir) |
| 173 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) | 173 scm.GetCasedPath(self.root_dir).AndReturn(self.root_dir) |
| 174 result1 = { "Repository Root": "Some root" } | 174 result1 = { "Repository Root": "Some root" } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 info = scm.SVN.CaptureStatus('.') | 304 info = scm.SVN.CaptureStatus('.') |
| 305 expected = [ | 305 expected = [ |
| 306 ('? ', 'unversionned_file.txt'), | 306 ('? ', 'unversionned_file.txt'), |
| 307 ('M ', 'build\\internal\\essential.vsprops'), | 307 ('M ', 'build\\internal\\essential.vsprops'), |
| 308 ('A + ', 'chrome\\app\\d'), | 308 ('A + ', 'chrome\\app\\d'), |
| 309 ('MM ', 'chrome\\app\\DEPS'), | 309 ('MM ', 'chrome\\app\\DEPS'), |
| 310 ('C ', 'scripts\\master\\factory\\gclient_factory.py'), | 310 ('C ', 'scripts\\master\\factory\\gclient_factory.py'), |
| 311 ] | 311 ] |
| 312 self.assertEquals(sorted(info), sorted(expected)) | 312 self.assertEquals(sorted(info), sorted(expected)) |
| 313 | 313 |
| 314 def testRun(self): | |
| 315 param2 = 'bleh' | |
| 316 scm.gclient_utils.CheckCallAndFilterAndHeader( | |
| 317 ['svn', 'foo', 'bar'], cwd=param2, | |
| 318 always=True).AndReturn(None) | |
| 319 self.mox.ReplayAll() | |
| 320 scm.SVN.Run(['foo', 'bar'], cwd=param2) | |
| 321 | |
| 322 def testCaptureStatusEmpty(self): | 314 def testCaptureStatusEmpty(self): |
| 323 text = r"""<?xml version="1.0"?> | 315 text = r"""<?xml version="1.0"?> |
| 324 <status> | 316 <status> |
| 325 <target | 317 <target |
| 326 path="perf"> | 318 path="perf"> |
| 327 </target> | 319 </target> |
| 328 </status>""" | 320 </status>""" |
| 329 proc = self.mox.CreateMockAnything() | 321 proc = self.mox.CreateMockAnything() |
| 330 scm.gclient_utils.Popen(['svn', 'status', '--xml'], | 322 scm.gclient_utils.Popen(['svn', 'status', '--xml'], |
| 331 cwd=None, | 323 cwd=None, |
| 332 stderr=None, | 324 stderr=None, |
| 333 stdout=scm.subprocess.PIPE).AndReturn(proc) | 325 stdout=scm.subprocess.PIPE).AndReturn(proc) |
| 334 proc.communicate().AndReturn((text, 0)) | 326 proc.communicate().AndReturn((text, 0)) |
| 335 self.mox.ReplayAll() | 327 self.mox.ReplayAll() |
| 336 info = scm.SVN.CaptureStatus(None) | 328 info = scm.SVN.CaptureStatus(None) |
| 337 self.assertEquals(info, []) | 329 self.assertEquals(info, []) |
| 338 | 330 |
| 339 | 331 |
| 340 if __name__ == '__main__': | 332 if __name__ == '__main__': |
| 341 import unittest | 333 import unittest |
| 342 unittest.main() | 334 unittest.main() |
| 343 | 335 |
| 344 # vim: ts=2:sw=2:tw=80:et: | 336 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |