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): | |
borenet
2014/02/06 16:21:47
This already succeeded, but there was no test.
iannucci
2014/02/06 23:05:11
Neat
| |
173 if not self.enabled: | |
174 return | |
175 # Git-svn | |
176 self.assertTrue(scm.GIT.IsGitSvn(checkout_root=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(checkout_root=git_dir)) | |
180 # Pure svn | |
181 svn_dir = scm.os.path.join(self.FAKE_REPOS.svn_checkout, 'trunk') | |
182 self.assertFalse(scm.GIT.IsGitSvn(checkout_root=svn_dir)) | |
183 | |
172 def testParseGitSvnSha1(self): | 184 def testParseGitSvnSha1(self): |
173 test_sha1 = 'a5c63ce8671922e5c59c0dea49ef4f9d4a3020c9' | 185 test_sha1 = 'a5c63ce8671922e5c59c0dea49ef4f9d4a3020c9' |
174 expected_output = test_sha1 + '\n' | 186 expected_output = test_sha1 + '\n' |
175 # Cygwin git-svn 1.7.9 prints extra escape sequences when run under | 187 # Cygwin git-svn 1.7.9 prints extra escape sequences when run under |
176 # TERM=xterm | 188 # TERM=xterm |
177 cygwin_output = test_sha1 + '\n\033[?1034h' | 189 cygwin_output = test_sha1 + '\n\033[?1034h' |
178 | 190 |
179 self.assertEquals(scm.GIT.ParseGitSvnSha1(expected_output), test_sha1) | 191 self.assertEquals(scm.GIT.ParseGitSvnSha1(expected_output), test_sha1) |
180 self.assertEquals(scm.GIT.ParseGitSvnSha1(cygwin_output), test_sha1) | 192 self.assertEquals(scm.GIT.ParseGitSvnSha1(cygwin_output), test_sha1) |
181 | 193 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 # Asserting the tree is not sufficient, svn status must come out clear too. | 478 # Asserting the tree is not sufficient, svn status must come out clear too. |
467 self.assertEquals('', self._capture(['status'])) | 479 self.assertEquals('', self._capture(['status'])) |
468 | 480 |
469 | 481 |
470 if __name__ == '__main__': | 482 if __name__ == '__main__': |
471 if '-v' in sys.argv: | 483 if '-v' in sys.argv: |
472 logging.basicConfig(level=logging.DEBUG) | 484 logging.basicConfig(level=logging.DEBUG) |
473 unittest.main() | 485 unittest.main() |
474 | 486 |
475 # vim: ts=2:sw=2:tw=80:et: | 487 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |