Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: tests/scm_unittest.py

Issue 795723003: Fix test failures on Ubuntu/Trusty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/gclient_smoketest.py ('k') | tests/submodule-merge-test.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 import logging 8 import logging
9 import os 9 import os
10 import sys 10 import sys
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 url_at_rev = self.svn_base + 'trunk/third_party@%s' 468 url_at_rev = self.svn_base + 'trunk/third_party@%s'
469 # Invalid or non-existent. 469 # Invalid or non-existent.
470 self.assertFalse(scm.SVN.IsValidRevision('url://totally_invalid/trunk/foo')) 470 self.assertFalse(scm.SVN.IsValidRevision('url://totally_invalid/trunk/foo'))
471 self.assertFalse(scm.SVN.IsValidRevision(url_at_rev % 0)) 471 self.assertFalse(scm.SVN.IsValidRevision(url_at_rev % 0))
472 self.assertFalse(scm.SVN.IsValidRevision(url_at_rev % 123)) 472 self.assertFalse(scm.SVN.IsValidRevision(url_at_rev % 123))
473 # Valid. 473 # Valid.
474 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 1)) 474 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 1))
475 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 2)) 475 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 2))
476 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 'HEAD')) 476 self.assertTrue(scm.SVN.IsValidRevision(url_at_rev % 'HEAD'))
477 477
478 def testRevert(self):
479 if not self.enabled:
480 return
481 # Mess around and make sure revert works for all corner cases.
482 # - svn add a file
483 # - svn add a file and delete it
484 # - Delete a file
485 # - svn delete a file
486 # - svn move a directory and svn rename files in it
487 # - add a directory tree.
488 def join(*args):
489 return scm.os.path.join(self.svn_root, *args)
490 self._capture(['move', 'foo', 'foo2'])
491 self._capture(
492 ['move',
493 scm.os.path.join('foo2', 'origin'),
494 scm.os.path.join('foo2', 'o')])
495 scm.os.remove(join('origin'))
496 self._capture(['propset', 'foo', 'bar', join('prout', 'origin')])
497 fake_repos.gclient_utils.rmtree(join('prout'))
498 with open(join('faa'), 'w') as f:
499 f.write('eh')
500 with open(join('faala'), 'w') as f:
501 f.write('oh')
502 self._capture(['add', join('faala')])
503 added_and_removed = join('added_and_removed')
504 with open(added_and_removed, 'w') as f:
505 f.write('oh')
506 self._capture(['add', added_and_removed])
507 scm.os.remove(added_and_removed)
508 # Make sure a tree of directories can be removed.
509 scm.os.makedirs(join('new_dir', 'subdir'))
510 with open(join('new_dir', 'subdir', 'newfile'), 'w') as f:
511 f.write('ah!')
512 self._capture(['add', join('new_dir')])
513 self._capture(['add', join('new_dir', 'subdir')])
514 self._capture(['add', join('new_dir', 'subdir', 'newfile')])
515 # A random file in an added directory confuses svn.
516 scm.os.makedirs(join('new_dir2', 'subdir'))
517 with open(join('new_dir2', 'subdir', 'newfile'), 'w') as f:
518 f.write('ah!')
519 self._capture(['add', join('new_dir2')])
520 self._capture(['add', join('new_dir2', 'subdir')])
521 self._capture(['add', join('new_dir2', 'subdir', 'newfile')])
522 with open(join('new_dir2', 'subdir', 'unversionedfile'), 'w') as f:
523 f.write('unadded file!')
524
525 scm.SVN.Revert(self.svn_root)
526 self._capture(['update', '--revision', 'base'])
527
528 self.assertTree(self.tree, self.svn_root)
529 # Asserting the tree is not sufficient, svn status must come out clear too.
530 self.assertEquals('', self._capture(['status']))
531
532 478
533 if __name__ == '__main__': 479 if __name__ == '__main__':
534 if '-v' in sys.argv: 480 if '-v' in sys.argv:
535 logging.basicConfig(level=logging.DEBUG) 481 logging.basicConfig(level=logging.DEBUG)
536 unittest.main() 482 unittest.main()
537 483
538 # vim: ts=2:sw=2:tw=80:et: 484 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gclient_smoketest.py ('k') | tests/submodule-merge-test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698