| OLD | NEW |
| 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 scm.py.""" | 6 """Unit tests for scm.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1101,W0403 | 8 # pylint: disable=E1101,W0403 |
| 9 from __future__ import with_statement | 9 from __future__ import with_statement |
| 10 import logging | 10 import logging |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 scm.SVN.Capture(['status', '--xml']).AndReturn(text) | 254 scm.SVN.Capture(['status', '--xml']).AndReturn(text) |
| 255 self.mox.ReplayAll() | 255 self.mox.ReplayAll() |
| 256 info = scm.SVN.CaptureStatus(None) | 256 info = scm.SVN.CaptureStatus(None) |
| 257 self.assertEquals(info, []) | 257 self.assertEquals(info, []) |
| 258 | 258 |
| 259 | 259 |
| 260 class RealSvnTest(fake_repos.FakeReposTestBase): | 260 class RealSvnTest(fake_repos.FakeReposTestBase): |
| 261 # Tests that work with a checkout. | 261 # Tests that work with a checkout. |
| 262 def setUp(self): | 262 def setUp(self): |
| 263 super(RealSvnTest, self).setUp() | 263 super(RealSvnTest, self).setUp() |
| 264 self.FAKE_REPOS.set_up_svn() | 264 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 265 self.svn_root = scm.os.path.join(self.root_dir, 'base') | 265 if self.enabled: |
| 266 scm.SVN.Capture( | 266 self.svn_root = scm.os.path.join(self.root_dir, 'base') |
| 267 ['checkout', self.svn_base + 'trunk/third_party', 'base'], | 267 scm.SVN.Capture( |
| 268 cwd=self.root_dir) | 268 ['checkout', self.svn_base + 'trunk/third_party', 'base'], |
| 269 self.tree = self.mangle_svn_tree(('trunk/third_party@-1', ''),) | 269 cwd=self.root_dir) |
| 270 self.tree = self.mangle_svn_tree(('trunk/third_party@-1', ''),) |
| 270 | 271 |
| 271 def _capture(self, cmd, **kwargs): | 272 def _capture(self, cmd, **kwargs): |
| 272 kwargs.setdefault('cwd', self.svn_root) | 273 kwargs.setdefault('cwd', self.svn_root) |
| 273 return scm.SVN.Capture(cmd, **kwargs) | 274 return scm.SVN.Capture(cmd, **kwargs) |
| 274 | 275 |
| 275 def testCheckout(self): | 276 def testCheckout(self): |
| 277 if not self.enabled: |
| 278 return |
| 276 # Checkout and verify the tree. | 279 # Checkout and verify the tree. |
| 277 self.assertTree(self.tree, self.svn_root) | 280 self.assertTree(self.tree, self.svn_root) |
| 278 | 281 |
| 279 def testRevert(self): | 282 def testRevert(self): |
| 283 if not self.enabled: |
| 284 return |
| 280 # Mess around and make sure revert works for all corner cases. | 285 # Mess around and make sure revert works for all corner cases. |
| 281 # - svn add a file | 286 # - svn add a file |
| 282 # - svn add a file and delete it | 287 # - svn add a file and delete it |
| 283 # - Delete a file | 288 # - Delete a file |
| 284 # - svn delete a file | 289 # - svn delete a file |
| 285 # - svn move a directory and svn rename files in it | 290 # - svn move a directory and svn rename files in it |
| 286 # - add a directory tree. | 291 # - add a directory tree. |
| 287 def join(*args): | 292 def join(*args): |
| 288 return scm.os.path.join(self.svn_root, *args) | 293 return scm.os.path.join(self.svn_root, *args) |
| 289 self._capture(['move', 'foo', 'foo2']) | 294 self._capture(['move', 'foo', 'foo2']) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 # Asserting the tree is not sufficient, svn status must come out clear too. | 333 # Asserting the tree is not sufficient, svn status must come out clear too. |
| 329 self.assertEquals('', self._capture(['status'])) | 334 self.assertEquals('', self._capture(['status'])) |
| 330 | 335 |
| 331 | 336 |
| 332 if __name__ == '__main__': | 337 if __name__ == '__main__': |
| 333 if '-v' in sys.argv: | 338 if '-v' in sys.argv: |
| 334 logging.basicConfig(level=logging.DEBUG) | 339 logging.basicConfig(level=logging.DEBUG) |
| 335 unittest.main() | 340 unittest.main() |
| 336 | 341 |
| 337 # vim: ts=2:sw=2:tw=80:et: | 342 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |