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

Side by Side Diff: tests/gclient_scm_test.py

Issue 8431021: Handle cases where '.' show up in svn status and is deleted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Add another test Created 9 years, 1 month 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 | « scm.py ('k') | no next file » | 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) 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 gclient_scm.py.""" 6 """Unit tests for gclient_scm.py."""
7 7
8 # pylint: disable=E1101,E1103,W0403 8 # pylint: disable=E1101,E1103,W0403
9 9
10 # Import before super_mox to keep valid references. 10 # Import before super_mox to keep valid references.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 scm.revert(options, self.args, files_list) 189 scm.revert(options, self.args, files_list)
190 self.checkstdout( 190 self.checkstdout(
191 '\n_____ %s is not a valid svn checkout, synching instead\n' % 191 '\n_____ %s is not a valid svn checkout, synching instead\n' %
192 self.relpath) 192 self.relpath)
193 193
194 def testRevertNone(self): 194 def testRevertNone(self):
195 options = self.Options(verbose=True) 195 options = self.Options(verbose=True)
196 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 196 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
197 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) 197 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
198 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([]) 198 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn([])
199 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
199 gclient_scm.scm.SVN.RunAndGetFileList( 200 gclient_scm.scm.SVN.RunAndGetFileList(
200 options.verbose, 201 options.verbose,
201 ['update', '--revision', 'BASE', '--ignore-externals'], 202 ['update', '--revision', 'BASE', '--ignore-externals'],
202 cwd=self.base_path, 203 cwd=self.base_path,
203 file_list=mox.IgnoreArg()) 204 file_list=mox.IgnoreArg())
204 205
205 self.mox.ReplayAll() 206 self.mox.ReplayAll()
206 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 207 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
207 relpath=self.relpath) 208 relpath=self.relpath)
208 file_list = [] 209 file_list = []
209 scm.revert(options, self.args, file_list) 210 scm.revert(options, self.args, file_list)
210 211
211 def testRevertDirectory(self): 212 def testRevertDirectory(self):
212 options = self.Options(verbose=True) 213 options = self.Options(verbose=True)
213 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 214 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
214 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) 215 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
215 items = [ 216 items = [
216 ('~ ', 'a'), 217 ('~ ', 'a'),
217 ] 218 ]
218 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items) 219 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items)
219 file_path = join(self.base_path, 'a') 220 file_path = join(self.base_path, 'a')
220 gclient_scm.os.path.exists(file_path).AndReturn(True) 221 gclient_scm.os.path.exists(file_path).AndReturn(True)
221 gclient_scm.os.path.isfile(file_path).AndReturn(False) 222 gclient_scm.os.path.isfile(file_path).AndReturn(False)
222 gclient_scm.os.path.islink(file_path).AndReturn(False) 223 gclient_scm.os.path.islink(file_path).AndReturn(False)
223 gclient_scm.os.path.isdir(file_path).AndReturn(True) 224 gclient_scm.os.path.isdir(file_path).AndReturn(True)
224 gclient_scm.gclient_utils.RemoveDirectory(file_path) 225 gclient_scm.gclient_utils.RemoveDirectory(file_path)
226 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
225 gclient_scm.scm.SVN.RunAndGetFileList( 227 gclient_scm.scm.SVN.RunAndGetFileList(
226 options.verbose, 228 options.verbose,
227 ['update', '--revision', 'BASE', '--ignore-externals'], 229 ['update', '--revision', 'BASE', '--ignore-externals'],
228 cwd=self.base_path, 230 cwd=self.base_path,
229 file_list=mox.IgnoreArg()) 231 file_list=mox.IgnoreArg())
230 232
231 self.mox.ReplayAll() 233 self.mox.ReplayAll()
232 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 234 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
233 relpath=self.relpath) 235 relpath=self.relpath)
234 file_list2 = [] 236 file_list2 = []
235 scm.revert(options, self.args, file_list2) 237 scm.revert(options, self.args, file_list2)
236 self.checkstdout(('%s\n' % file_path)) 238 self.checkstdout(('%s\n' % file_path))
237 239
240 def testRevertDot(self):
241 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update')
242 options = self.Options(verbose=True)
243 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
244 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True)
245 items = [
246 ('~ ', '.'),
247 ]
248 gclient_scm.scm.SVN.CaptureStatus(self.base_path).AndReturn(items)
249 file_path = join(self.base_path, '.')
250 gclient_scm.os.path.exists(file_path).AndReturn(True)
251 gclient_scm.os.path.isfile(file_path).AndReturn(False)
252 gclient_scm.os.path.islink(file_path).AndReturn(False)
253 gclient_scm.os.path.isdir(file_path).AndReturn(True)
254 gclient_scm.gclient_utils.RemoveDirectory(file_path)
255 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
256 # The mock is unbound so self is not necessary.
257 # pylint: disable=E1120
258 gclient_scm.SVNWrapper.update(options, [], ['.'])
259
260 self.mox.ReplayAll()
261 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
262 relpath=self.relpath)
263 file_list2 = []
264 scm.revert(options, self.args, file_list2)
265 self.checkstdout(('%s\n' % file_path))
266
238 def testStatus(self): 267 def testStatus(self):
239 options = self.Options(verbose=True) 268 options = self.Options(verbose=True)
240 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 269 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
241 gclient_scm.scm.SVN.RunAndGetFileList( 270 gclient_scm.scm.SVN.RunAndGetFileList(
242 options.verbose, 271 options.verbose,
243 ['status'] + self.args + ['--ignore-externals'], 272 ['status'] + self.args + ['--ignore-externals'],
244 cwd=self.base_path, 273 cwd=self.base_path,
245 file_list=[]).AndReturn(None) 274 file_list=[]).AndReturn(None)
246 275
247 self.mox.ReplayAll() 276 self.mox.ReplayAll()
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 962
934 if __name__ == '__main__': 963 if __name__ == '__main__':
935 if '-v' in sys.argv: 964 if '-v' in sys.argv:
936 logging.basicConfig( 965 logging.basicConfig(
937 level=logging.DEBUG, 966 level=logging.DEBUG,
938 format='%(asctime).19s %(levelname)s %(filename)s:' 967 format='%(asctime).19s %(levelname)s %(filename)s:'
939 '%(lineno)s %(message)s') 968 '%(lineno)s %(message)s')
940 unittest.main() 969 unittest.main()
941 970
942 # vim: ts=2:sw=2:tw=80:et: 971 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698