OLD | NEW |
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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # pylint: disable=E1103 | 8 # pylint: disable=E1103 |
9 | 9 |
10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 def testRevertDot(self): | 284 def testRevertDot(self): |
285 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') | 285 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') |
286 options = self.Options(verbose=True) | 286 options = self.Options(verbose=True) |
287 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 287 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
288 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) | 288 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
289 items = [ | 289 items = [ |
290 ('~ ', '.'), | 290 ('~ ', '.'), |
291 ] | 291 ] |
292 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) | 292 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) |
293 file_path = join(self.base_path, '.') | 293 # RemoveDirectory() doesn't work on path ending with '.', like 'foo/.'. |
| 294 file_path = self.base_path |
294 gclient_scm.os.path.exists(file_path).AndReturn(True) | 295 gclient_scm.os.path.exists(file_path).AndReturn(True) |
295 gclient_scm.os.path.isfile(file_path).AndReturn(False) | 296 gclient_scm.os.path.isfile(file_path).AndReturn(False) |
296 gclient_scm.os.path.islink(file_path).AndReturn(False) | 297 gclient_scm.os.path.islink(file_path).AndReturn(False) |
297 gclient_scm.os.path.isdir(file_path).AndReturn(True) | 298 gclient_scm.os.path.isdir(file_path).AndReturn(True) |
298 gclient_scm.gclient_utils.RemoveDirectory(file_path) | 299 gclient_scm.gclient_utils.RemoveDirectory(file_path) |
299 # pylint: disable=E1120 | 300 # pylint: disable=E1120 |
300 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 301 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
301 gclient_scm.SVNWrapper.update(options, [], ['.']) | 302 gclient_scm.SVNWrapper.update(options, [], ['.']) |
302 | 303 |
303 self.mox.ReplayAll() | 304 self.mox.ReplayAll() |
304 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 305 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
305 relpath=self.relpath) | 306 relpath=self.relpath) |
306 file_list2 = [] | 307 file_list2 = [] |
307 scm.revert(options, self.args, file_list2) | 308 scm.revert(options, self.args, file_list2) |
308 self.checkstdout(('%s\n' % file_path)) | 309 self.checkstdout(('%s\n' % os.path.join(file_path, '.'))) |
309 | 310 |
310 def testStatus(self): | 311 def testStatus(self): |
311 options = self.Options(verbose=True) | 312 options = self.Options(verbose=True) |
312 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 313 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
313 gclient_scm.scm.SVN.RunAndGetFileList( | 314 gclient_scm.scm.SVN.RunAndGetFileList( |
314 options.verbose, | 315 options.verbose, |
315 ['status'] + self.args + ['--ignore-externals'], | 316 ['status'] + self.args + ['--ignore-externals'], |
316 cwd=self.base_path, | 317 cwd=self.base_path, |
317 file_list=[]).AndReturn(None) | 318 file_list=[]).AndReturn(None) |
318 | 319 |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1221 |
1221 if __name__ == '__main__': | 1222 if __name__ == '__main__': |
1222 if '-v' in sys.argv: | 1223 if '-v' in sys.argv: |
1223 logging.basicConfig( | 1224 logging.basicConfig( |
1224 level=logging.DEBUG, | 1225 level=logging.DEBUG, |
1225 format='%(asctime).19s %(levelname)s %(filename)s:' | 1226 format='%(asctime).19s %(levelname)s %(filename)s:' |
1226 '%(lineno)s %(message)s') | 1227 '%(lineno)s %(message)s') |
1227 unittest.main() | 1228 unittest.main() |
1228 | 1229 |
1229 # vim: ts=2:sw=2:tw=80:et: | 1230 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |