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

Unified Diff: tests/checkout_test.py

Issue 8038056: Fix handling of file renames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rebase against HEAD Created 9 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « patch.py ('k') | tests/patch_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/checkout_test.py
diff --git a/tests/checkout_test.py b/tests/checkout_test.py
index 21cd67150b3543e5022a0f680836f1e23f903216..1428bd7308729ba54d716815b38f32925953a3e7 100755
--- a/tests/checkout_test.py
+++ b/tests/checkout_test.py
@@ -40,6 +40,11 @@ class FakeRepos(fake_repos.FakeReposBase):
'--non-interactive', '--no-auth-cache',
'--username', self.USERS[0][0], '--password', self.USERS[0][1]])
assert os.path.isdir(os.path.join(self.svn_checkout, '.svn'))
+ self._commit_svn(self._tree_1())
+ self._commit_svn(self._tree_2())
+
+ @staticmethod
+ def _tree_1():
fs = {}
fs['trunk/origin'] = 'svn@1'
fs['trunk/codereview.settings'] = (
@@ -63,11 +68,26 @@ class FakeRepos(fake_repos.FakeReposBase):
'ooo\n'
'pp\n'
'q\n')
- self._commit_svn(fs)
+ return fs
+
+ @classmethod
+ def _tree_2(cls):
+ fs = cls._tree_1()
fs['trunk/origin'] = 'svn@2\n'
fs['trunk/extra'] = 'dummy\n'
fs['trunk/bin_file'] = '\x00'
- self._commit_svn(fs)
+ fs['trunk/chromeos/views/DOMui_menu_widget.h'] = (
+ '// Copyright (c) 2010\n'
+ '// Use of this source code\n'
+ '// found in the LICENSE file.\n'
+ '\n'
+ '#ifndef DOM\n'
+ '#define DOM\n'
+ '#pragma once\n'
+ '\n'
+ '#include <string>\n'
+ '#endif\n')
+ return fs
def populateGit(self):
raise NotImplementedError()
@@ -100,11 +120,10 @@ class BaseTest(fake_repos.FakeReposTestBase):
def get_patches(self):
return patch.PatchSet([
+ patch.FilePatchDiff('new_dir/subdir/new_file', GIT.NEW_SUBDIR, []),
+ patch.FilePatchDiff('chrome/file.cc', GIT.PATCH, []),
# TODO(maruel): Test with is_new == False.
patch.FilePatchBinary('bin_file', '\x00', [], is_new=True),
- patch.FilePatchDiff(
- 'chrome/file.cc', GIT.PATCH, []),
- patch.FilePatchDiff('new_dir/subdir/new_file', GIT.NEW_SUBDIR, []),
patch.FilePatchDelete('extra', False),
])
@@ -201,6 +220,35 @@ class BaseTest(fake_repos.FakeReposTestBase):
self.assertEquals(len(expected), len(results))
self.assertEquals(expected, results)
+ def _check_move(self, co):
+ """Makes sure file moves are handled correctly."""
+ co.prepare(None)
+ patchset = patch.PatchSet([
+ patch.FilePatchDelete('chromeos/views/DOMui_menu_widget.h', False),
+ patch.FilePatchDiff(
+ 'chromeos/views/webui_menu_widget.h', GIT.RENAME_PARTIAL, []),
+ ])
+ co.apply_patch(patchset)
+ # Make sure chromeos/views/DOMui_menu_widget.h is deleted and
+ # chromeos/views/webui_menu_widget.h is correctly created.
+ root = os.path.join(self.root_dir, self.name)
+ tree = self.get_trunk(False)
+ del tree['chromeos/views/DOMui_menu_widget.h']
+ tree['chromeos/views/webui_menu_widget.h'] = (
+ '// Copyright (c) 2011\n'
+ '// Use of this source code\n'
+ '// found in the LICENSE file.\n'
+ '\n'
+ '#ifndef WEB\n'
+ '#define WEB\n'
+ '#pragma once\n'
+ '\n'
+ '#include <string>\n'
+ '#endif\n')
+ #print patchset[0].get()
+ #print fake_repos.read_tree(root)
+ self.assertTree(tree, root)
+
class SvnBaseTest(BaseTest):
def setUp(self):
@@ -349,6 +397,9 @@ class SvnCheckout(SvnBaseTest):
def testPrepare(self):
self._test_prepare(self._get_co(None))
+ def testMove(self):
+ self._check_move(self._get_co(None))
+
class GitSvnCheckout(SvnBaseTest):
name = 'foo.git'
@@ -419,6 +470,9 @@ class GitSvnCheckout(SvnBaseTest):
co.prepare = prepare
self._test_prepare(co)
+ def testMove(self):
+ self._check_move(self._get_co(None))
+
class RawCheckout(SvnBaseTest):
def setUp(self):
@@ -482,6 +536,9 @@ class RawCheckout(SvnBaseTest):
self._test_prepare(co)
self.assertEquals([], revs)
+ def testMove(self):
+ self._check_move(self._get_co(None))
+
class ReadOnlyCheckout(SvnBaseTest):
# Use SvnCheckout as the backed since it support read-only checkouts too.
@@ -513,6 +570,9 @@ class ReadOnlyCheckout(SvnBaseTest):
def testPrepare(self):
self._test_prepare(self._get_co(None))
+ def testMove(self):
+ self._check_move(self._get_co(None))
+
if __name__ == '__main__':
if '-v' in sys.argv:
« no previous file with comments | « patch.py ('k') | tests/patch_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698