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

Side by Side Diff: tests/scm_unittest.py

Issue 164053003: Re-re-land gclient deletion of mismatching checkouts again (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Another attempt of gclient: delete mismatching checkouts Created 6 years, 9 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 | « tests/gclient_utils_test.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 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
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
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
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:
OLDNEW
« no previous file with comments | « tests/gclient_utils_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698