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 # pylint: disable=E1101,W0403 | 8 # pylint: disable=E1101,W0403 |
9 | 9 |
10 # Fixes include path. | 10 # Fixes include path. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 # Checkout and verify the tree. | 260 # Checkout and verify the tree. |
261 self.assertTree(self.tree, self.svn_root) | 261 self.assertTree(self.tree, self.svn_root) |
262 | 262 |
263 def testRevert(self): | 263 def testRevert(self): |
264 # Mess around and make sure revert works for all corner cases. | 264 # Mess around and make sure revert works for all corner cases. |
265 # - svn add a file | 265 # - svn add a file |
266 # - svn add a file and delete it | 266 # - svn add a file and delete it |
267 # - Delete a file | 267 # - Delete a file |
268 # - svn delete a file | 268 # - svn delete a file |
269 # - svn move a directory and svn rename files in it | 269 # - svn move a directory and svn rename files in it |
| 270 # - add a directory tree. |
| 271 def join(*args): |
| 272 return scm.os.path.join(self.svn_root, *args) |
270 self._capture(['move', 'foo', 'foo2']) | 273 self._capture(['move', 'foo', 'foo2']) |
271 self._capture( | 274 self._capture( |
272 ['move', | 275 ['move', |
273 scm.os.path.join('foo2', 'origin'), | 276 scm.os.path.join('foo2', 'origin'), |
274 scm.os.path.join('foo2', 'o')]) | 277 scm.os.path.join('foo2', 'o')]) |
275 scm.os.remove(scm.os.path.join(self.svn_root, 'origin')) | 278 scm.os.remove(join('origin')) |
276 self._capture( | 279 self._capture(['propset', 'foo', 'bar', join('prout', 'origin')]) |
277 ['propset', 'foo', 'bar', | 280 fake_repos.gclient_utils.rmtree(join('prout')) |
278 scm.os.path.join(self.svn_root, 'prout', 'origin')]) | 281 with open(join('faa'), 'w') as f: |
279 fake_repos.gclient_utils.rmtree(scm.os.path.join(self.svn_root, 'prout')) | |
280 with open(scm.os.path.join(self.svn_root, 'faa'), 'w') as f: | |
281 f.write('eh') | 282 f.write('eh') |
282 with open(scm.os.path.join(self.svn_root, 'faala'), 'w') as f: | 283 with open(join('faala'), 'w') as f: |
283 f.write('oh') | 284 f.write('oh') |
284 self._capture(['add', scm.os.path.join(self.svn_root, 'faala')]) | 285 self._capture(['add', join('faala')]) |
285 added_and_removed = scm.os.path.join(self.svn_root, 'added_and_removed') | 286 added_and_removed = join('added_and_removed') |
286 with open(added_and_removed, 'w') as f: | 287 with open(added_and_removed, 'w') as f: |
287 f.write('oh') | 288 f.write('oh') |
288 self._capture(['add', added_and_removed]) | 289 self._capture(['add', added_and_removed]) |
289 scm.os.remove(added_and_removed) | 290 scm.os.remove(added_and_removed) |
| 291 # Make sure a tree of directories can be removed. |
| 292 scm.os.makedirs(join('new_dir', 'subdir')) |
| 293 with open(join('new_dir', 'subdir', 'newfile'), 'w') as f: |
| 294 f.write('ah!') |
| 295 self._capture(['add', join('new_dir')]) |
| 296 self._capture(['add', join('new_dir', 'subdir')]) |
| 297 self._capture(['add', join('new_dir', 'subdir', 'newfile')]) |
| 298 # A random file in an added directory confuses svn. |
| 299 scm.os.makedirs(join('new_dir2', 'subdir')) |
| 300 with open(join('new_dir2', 'subdir', 'newfile'), 'w') as f: |
| 301 f.write('ah!') |
| 302 self._capture(['add', join('new_dir2')]) |
| 303 self._capture(['add', join('new_dir2', 'subdir')]) |
| 304 self._capture(['add', join('new_dir2', 'subdir', 'newfile')]) |
| 305 with open(join('new_dir2', 'subdir', 'unversionedfile'), 'w') as f: |
| 306 f.write('unadded file!') |
290 | 307 |
291 scm.SVN.Revert(self.svn_root) | 308 scm.SVN.Revert(self.svn_root) |
292 self._capture(['update', '--revision', 'base']) | 309 self._capture(['update', '--revision', 'base']) |
293 | 310 |
294 self.assertTree(self.tree, self.svn_root) | 311 self.assertTree(self.tree, self.svn_root) |
295 # Asserting the tree is not sufficient, svn status must come out clear too. | 312 # Asserting the tree is not sufficient, svn status must come out clear too. |
296 self.assertEquals('', self._capture(['status'])) | 313 self.assertEquals('', self._capture(['status'])) |
297 | 314 |
298 | 315 |
299 if __name__ == '__main__': | 316 if __name__ == '__main__': |
300 import unittest | 317 import unittest |
301 unittest.main() | 318 unittest.main() |
302 | 319 |
303 # vim: ts=2:sw=2:tw=80:et: | 320 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |