From c2c78f7f025328d6cc73f93e87b04328f7a2b6dc Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Thu, 17 Sep 2009 17:48:01 +0000 Subject: [PATCH] Add a new test case for SCMWrapper.revert. Add a test case for the UnversionedUnexpected file code path. TEST=This test case will catch the bug fixed by r26425. BUG=none Patch contributed by msb@ Review URL: http://codereview.chromium.org/214005 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@26458 0039d316-1c4b-4281-b951-d872f2087c98 --- tests/gclient_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/gclient_test.py b/tests/gclient_test.py index eb3cd7798..305736d53 100644 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -36,6 +36,7 @@ class BaseTestCase(super_mox.SuperMoxTestBase): super_mox.SuperMoxTestBase.setUp(self) self.mox.StubOutWithMock(gclient.os.path, 'exists') self.mox.StubOutWithMock(gclient.os.path, 'isdir') + self.mox.StubOutWithMock(gclient.os, 'remove') self.mox.StubOutWithMock(gclient.sys, 'stdout') self.mox.StubOutWithMock(gclient_utils, 'subprocess') # These are not tested. @@ -1117,6 +1118,26 @@ class SCMWrapperTestCase(GClientBaseTestCase): file_list = [] scm.revert(options, self.args, file_list) + def testRevertUnversionedUnexpectedFile(self): + options = self.Options(verbose=True) + base_path = os.path.join(self.root_dir, self.relpath) + gclient.os.path.isdir(base_path).AndReturn(True) + items = [ + ('~ ', 'a'), + ] + gclient_scm.CaptureSVNStatus(base_path).AndReturn(items) + file_path = os.path.join(base_path, 'a') + print(file_path) + gclient_scm.os.remove(file_path).AndRaise(EnvironmentError()) + gclient_utils.RemoveDirectory(file_path) + gclient_scm.RunSVN(['revert', 'a'], base_path) + + self.mox.ReplayAll() + scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, + relpath=self.relpath) + file_list = [] + scm.revert(options, self.args, file_list) + def testStatus(self): options = self.Options(verbose=True) base_path = os.path.join(self.root_dir, self.relpath)