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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 def testGetUsableRevGitSvn(self): | 1089 def testGetUsableRevGitSvn(self): |
1090 # pylint: disable=E1101 | 1090 # pylint: disable=E1101 |
1091 options = self.Options() | 1091 options = self.Options() |
1092 too_big = str(1e7) | 1092 too_big = str(1e7) |
1093 | 1093 |
1094 # Pretend like the git-svn repo's HEAD is at r2. | 1094 # Pretend like the git-svn repo's HEAD is at r2. |
1095 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True) | 1095 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True) |
1096 gclient_scm.scm.GIT.GetGitSvnHeadRev(cwd=self.base_path).MultipleTimes( | 1096 gclient_scm.scm.GIT.GetGitSvnHeadRev(cwd=self.base_path).MultipleTimes( |
1097 ).AndReturn(2) | 1097 ).AndReturn(2) |
1098 | 1098 |
1099 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetSha1ForSvnRev', True) | 1099 self.mox.StubOutWithMock( |
| 1100 gclient_scm.scm.GIT, 'GetBlessedSha1ForSvnRev', True) |
1100 # r1 -> first fake hash, r3 -> second fake hash. | 1101 # r1 -> first fake hash, r3 -> second fake hash. |
1101 gclient_scm.scm.GIT.GetSha1ForSvnRev(cwd=self.base_path, rev='1' | 1102 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='1' |
1102 ).AndReturn(self.fake_hash_1) | 1103 ).AndReturn(self.fake_hash_1) |
1103 gclient_scm.scm.GIT.GetSha1ForSvnRev(cwd=self.base_path, rev='3' | 1104 gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='3' |
1104 ).MultipleTimes().AndReturn(self.fake_hash_2) | 1105 ).MultipleTimes().AndReturn(self.fake_hash_2) |
1105 | 1106 |
1106 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev. | 1107 # Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev. |
1107 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) | 1108 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) |
1108 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1109 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
1109 cwd=self.base_path).AndReturn('blah') | 1110 cwd=self.base_path).AndReturn('blah') |
1110 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) | 1111 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) |
1111 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1112 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
1112 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') | 1113 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') |
1113 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1114 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 | 1176 |
1176 if __name__ == '__main__': | 1177 if __name__ == '__main__': |
1177 if '-v' in sys.argv: | 1178 if '-v' in sys.argv: |
1178 logging.basicConfig( | 1179 logging.basicConfig( |
1179 level=logging.DEBUG, | 1180 level=logging.DEBUG, |
1180 format='%(asctime).19s %(levelname)s %(filename)s:' | 1181 format='%(asctime).19s %(levelname)s %(filename)s:' |
1181 '%(lineno)s %(message)s') | 1182 '%(lineno)s %(message)s') |
1182 unittest.main() | 1183 unittest.main() |
1183 | 1184 |
1184 # vim: ts=2:sw=2:tw=80:et: | 1185 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |