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

Side by Side Diff: tests/gclient_scm_test.py

Issue 327803006: Added common git 'fetch' function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fixed nit Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_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) 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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1260
1261 self.mox.StubOutWithMock( 1261 self.mox.StubOutWithMock(
1262 gclient_scm.scm.GIT, 'GetBlessedSha1ForSvnRev', True) 1262 gclient_scm.scm.GIT, 'GetBlessedSha1ForSvnRev', True)
1263 # r1 -> first fake hash, r3 -> second fake hash. 1263 # r1 -> first fake hash, r3 -> second fake hash.
1264 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='1' 1264 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='1'
1265 ).AndReturn(self.fake_hash_1) 1265 ).AndReturn(self.fake_hash_1)
1266 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='3' 1266 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='3'
1267 ).MultipleTimes().AndReturn(self.fake_hash_2) 1267 ).MultipleTimes().AndReturn(self.fake_hash_2)
1268 1268
1269 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev. 1269 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev.
1270 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Fetch', True)
1270 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) 1271 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True)
1271 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], 1272 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
1272 cwd=self.base_path).AndReturn('blah') 1273 cwd=self.base_path).AndReturn('blah')
1273 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) 1274 # pylint: disable=E1120
1274 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) 1275 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
1275 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') 1276 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr')
1276 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], 1277 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
1277 cwd=self.base_path).AndRaise(error) 1278 cwd=self.base_path).AndRaise(error)
1279 gclient_scm.GitWrapper._Fetch(options)
1278 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) 1280 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
1279 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) 1281 gclient_scm.GitWrapper._Fetch(options)
1280 1282
1281 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) 1283 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
1282 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( 1284 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
1283 ).AndReturn(True) 1285 ).AndReturn(True)
1284 1286
1285 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) 1287 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
1286 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 1288 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
1287 ).AndReturn(True) 1289 ).AndReturn(True)
1288 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big 1290 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big
1289 ).MultipleTimes(2).AndReturn(False) 1291 ).MultipleTimes(2).AndReturn(False)
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 1582
1581 if __name__ == '__main__': 1583 if __name__ == '__main__':
1582 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL 1584 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL
1583 logging.basicConfig( 1585 logging.basicConfig(
1584 level=level, 1586 level=level,
1585 format='%(asctime).19s %(levelname)s %(filename)s:' 1587 format='%(asctime).19s %(levelname)s %(filename)s:'
1586 '%(lineno)s %(message)s') 1588 '%(lineno)s %(message)s')
1587 unittest.main() 1589 unittest.main()
1588 1590
1589 # vim: ts=2:sw=2:tw=80:et: 1591 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698