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 scm.py.""" | 6 """Unit tests for scm.py.""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 kwargs.setdefault('cwd', self.clone_dir) | 162 kwargs.setdefault('cwd', self.clone_dir) |
163 return scm.GIT.Capture(cmd, **kwargs) | 163 return scm.GIT.Capture(cmd, **kwargs) |
164 | 164 |
165 def testGetGitSvnHeadRev(self): | 165 def testGetGitSvnHeadRev(self): |
166 if not self.enabled: | 166 if not self.enabled: |
167 return | 167 return |
168 self.assertEquals(scm.GIT.GetGitSvnHeadRev(cwd=self.clone_dir), 2) | 168 self.assertEquals(scm.GIT.GetGitSvnHeadRev(cwd=self.clone_dir), 2) |
169 self._capture(['reset', '--hard', 'HEAD^']) | 169 self._capture(['reset', '--hard', 'HEAD^']) |
170 self.assertEquals(scm.GIT.GetGitSvnHeadRev(cwd=self.clone_dir), 1) | 170 self.assertEquals(scm.GIT.GetGitSvnHeadRev(cwd=self.clone_dir), 1) |
171 | 171 |
172 def testIsGitSvn(self): | |
173 if not self.enabled: | |
174 return | |
175 # Git-svn | |
176 self.assertTrue(scm.GIT.IsGitSvn(self.clone_dir)) | |
177 # Pure git | |
178 git_dir = scm.os.path.join(self.FAKE_REPOS.git_root, 'repo_1') | |
179 self.assertFalse(scm.GIT.IsGitSvn(git_dir)) | |
180 # Pure svn | |
181 svn_dir = scm.os.path.join(self.FAKE_REPOS.svn_checkout, 'trunk') | |
182 self.assertFalse(scm.GIT.IsGitSvn(svn_dir)) | |
183 | |
184 def testParseGitSvnSha1(self): | 172 def testParseGitSvnSha1(self): |
185 test_sha1 = 'a5c63ce8671922e5c59c0dea49ef4f9d4a3020c9' | 173 test_sha1 = 'a5c63ce8671922e5c59c0dea49ef4f9d4a3020c9' |
186 expected_output = test_sha1 + '\n' | 174 expected_output = test_sha1 + '\n' |
187 # Cygwin git-svn 1.7.9 prints extra escape sequences when run under | 175 # Cygwin git-svn 1.7.9 prints extra escape sequences when run under |
188 # TERM=xterm | 176 # TERM=xterm |
189 cygwin_output = test_sha1 + '\n\033[?1034h' | 177 cygwin_output = test_sha1 + '\n\033[?1034h' |
190 | 178 |
191 self.assertEquals(scm.GIT.ParseGitSvnSha1(expected_output), test_sha1) | 179 self.assertEquals(scm.GIT.ParseGitSvnSha1(expected_output), test_sha1) |
192 self.assertEquals(scm.GIT.ParseGitSvnSha1(cygwin_output), test_sha1) | 180 self.assertEquals(scm.GIT.ParseGitSvnSha1(cygwin_output), test_sha1) |
193 | 181 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 # Asserting the tree is not sufficient, svn status must come out clear too. | 466 # Asserting the tree is not sufficient, svn status must come out clear too. |
479 self.assertEquals('', self._capture(['status'])) | 467 self.assertEquals('', self._capture(['status'])) |
480 | 468 |
481 | 469 |
482 if __name__ == '__main__': | 470 if __name__ == '__main__': |
483 if '-v' in sys.argv: | 471 if '-v' in sys.argv: |
484 logging.basicConfig(level=logging.DEBUG) | 472 logging.basicConfig(level=logging.DEBUG) |
485 unittest.main() | 473 unittest.main() |
486 | 474 |
487 # vim: ts=2:sw=2:tw=80:et: | 475 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |