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

Side by Side Diff: tests/gclient_scm_test.py

Issue 796053002: Revert of Make gclient ready for the Blink (DEPS to main project) transition (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
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
« no previous file with comments | « testing_support/fake_repos.py ('k') | tests/gclient_smoketest.py » ('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 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 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 self.assertEquals(expected, strip_timestamps(value)) 1238 self.assertEquals(expected, strip_timestamps(value))
1239 1239
1240 def setUp(self): 1240 def setUp(self):
1241 BaseTestCase.setUp(self) 1241 BaseTestCase.setUp(self)
1242 self.fake_hash_1 = 't0ta11yf4k3' 1242 self.fake_hash_1 = 't0ta11yf4k3'
1243 self.fake_hash_2 = '3v3nf4k3r' 1243 self.fake_hash_2 = '3v3nf4k3r'
1244 self.url = 'git://foo' 1244 self.url = 'git://foo'
1245 self.root_dir = '/tmp' if sys.platform != 'win32' else 't:\\tmp' 1245 self.root_dir = '/tmp' if sys.platform != 'win32' else 't:\\tmp'
1246 self.relpath = 'fake' 1246 self.relpath = 'fake'
1247 self.base_path = os.path.join(self.root_dir, self.relpath) 1247 self.base_path = os.path.join(self.root_dir, self.relpath)
1248 self.backup_base_path = os.path.join(self.root_dir,
1249 'old_%s.git' % self.relpath)
1250 1248
1251 def tearDown(self): 1249 def tearDown(self):
1252 BaseTestCase.tearDown(self) 1250 BaseTestCase.tearDown(self)
1253 1251
1254 def testGetUsableRevGit(self): 1252 def testGetUsableRevGit(self):
1255 # pylint: disable=E1101 1253 # pylint: disable=E1101
1256 options = self.Options(verbose=True) 1254 options = self.Options(verbose=True)
1257 1255
1258 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) 1256 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
1259 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 1257 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 # We currently check for seemingly valid SVN revisions by assuming 6 digit 1347 # We currently check for seemingly valid SVN revisions by assuming 6 digit
1350 # numbers, so assure that numeric revs >= 1000000 don't work. 1348 # numbers, so assure that numeric revs >= 1000000 don't work.
1351 self.assertRaises(gclient_scm.gclient_utils.Error, 1349 self.assertRaises(gclient_scm.gclient_utils.Error,
1352 git_svn_scm.GetUsableRev, too_big, options) 1350 git_svn_scm.GetUsableRev, too_big, options)
1353 1351
1354 def testUpdateNoDotGit(self): 1352 def testUpdateNoDotGit(self):
1355 options = self.Options() 1353 options = self.Options()
1356 1354
1357 gclient_scm.os.path.isdir( 1355 gclient_scm.os.path.isdir(
1358 os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False) 1356 os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False)
1359 gclient_scm.os.path.exists(self.backup_base_path).AndReturn(False)
1360 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 1357 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
1361 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 1358 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1362 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') 1359 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1363 ).AndReturn(False) 1360 ).AndReturn(False)
1364 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True) 1361 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True)
1365 # pylint: disable=E1120 1362 # pylint: disable=E1120
1366 gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url, 1363 gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url,
1367 options) 1364 options)
1368 self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True) 1365 self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True)
1369 gclient_scm.subprocess2.check_output( 1366 gclient_scm.subprocess2.check_output(
(...skipping 10 matching lines...) Expand all
1380 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 1377 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1381 relpath=self.relpath) 1378 relpath=self.relpath)
1382 scm.update(options, None, []) 1379 scm.update(options, None, [])
1383 self.checkstdout('\n') 1380 self.checkstdout('\n')
1384 1381
1385 def testUpdateConflict(self): 1382 def testUpdateConflict(self):
1386 options = self.Options() 1383 options = self.Options()
1387 1384
1388 gclient_scm.os.path.isdir( 1385 gclient_scm.os.path.isdir(
1389 os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False) 1386 os.path.join(self.base_path, '.git', 'hooks')).AndReturn(False)
1390 gclient_scm.os.path.exists(self.backup_base_path).AndReturn(False)
1391 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 1387 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
1392 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 1388 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1393 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') 1389 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1394 ).AndReturn(False) 1390 ).AndReturn(False)
1395 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True) 1391 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True)
1396 # pylint: disable=E1120 1392 # pylint: disable=E1120
1397 gclient_scm.GitWrapper._Clone( 1393 gclient_scm.GitWrapper._Clone(
1398 'refs/remotes/origin/master', self.url, options 1394 'refs/remotes/origin/master', self.url, options
1399 ).AndRaise(gclient_scm.subprocess2.CalledProcessError(None, None, None, 1395 ).AndRaise(gclient_scm.subprocess2.CalledProcessError(None, None, None,
1400 None, None)) 1396 None, None))
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 1618
1623 if __name__ == '__main__': 1619 if __name__ == '__main__':
1624 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL 1620 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL
1625 logging.basicConfig( 1621 logging.basicConfig(
1626 level=level, 1622 level=level,
1627 format='%(asctime).19s %(levelname)s %(filename)s:' 1623 format='%(asctime).19s %(levelname)s %(filename)s:'
1628 '%(lineno)s %(message)s') 1624 '%(lineno)s %(message)s')
1629 unittest.main() 1625 unittest.main()
1630 1626
1631 # vim: ts=2:sw=2:tw=80:et: 1627 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « testing_support/fake_repos.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698