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

Side by Side Diff: tests/gclient_scm_test.py

Issue 497053002: Use a regex instead of shlex.split() to get remote url (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix Created 6 years, 4 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
« 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) 81 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True)
82 # Absolute path of the fake checkout directory. 82 # Absolute path of the fake checkout directory.
83 self.base_path = join(self.root_dir, self.relpath) 83 self.base_path = join(self.root_dir, self.relpath)
84 84
85 def tearDown(self): 85 def tearDown(self):
86 SuperMoxTestBase.tearDown(self) 86 SuperMoxTestBase.tearDown(self)
87 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists 87 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
88 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists 88 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
89 89
90 90
91 class BasicTests(SuperMoxTestBase):
92 def setUp(self):
93 SuperMoxTestBase.setUp(self)
94
95 def testGetFirstRemoteUrl(self):
96 REMOTE_STRINGS = [('remote.origin.url E:\\foo\\bar', 'E:\\foo\\bar'),
97 ('remote.origin.url /b/foo/bar', '/b/foo/bar'),
98 ('remote.origin.url https://foo/bar', 'https://foo/bar'),
99 ('remote.origin.url E:\\Fo Bar\\bax', 'E:\\Fo Bar\\bax'),
100 ('remote.origin.url git://what/"do', 'git://what/"do')]
101 FAKE_PATH = '/fake/path'
102 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture')
103 for question, _ in REMOTE_STRINGS:
104 gclient_scm.scm.GIT.Capture(
105 ['config', '--local', '--get-regexp', r'remote.*.url'],
106 cwd=FAKE_PATH).AndReturn(question)
107
108 self.mox.ReplayAll()
109
110 for _, answer in REMOTE_STRINGS:
111 self.assertEquals(gclient_scm.SCMWrapper._get_first_remote_url(FAKE_PATH),
112 answer)
113
114 def tearDown(self):
115 SuperMoxTestBase.tearDown(self)
116
117
91 class SVNWrapperTestCase(BaseTestCase): 118 class SVNWrapperTestCase(BaseTestCase):
92 class OptionsObject(object): 119 class OptionsObject(object):
93 def __init__(self, verbose=False, revision=None, force=False): 120 def __init__(self, verbose=False, revision=None, force=False):
94 self.verbose = verbose 121 self.verbose = verbose
95 self.revision = revision 122 self.revision = revision
96 self.manually_grab_svn_rev = True 123 self.manually_grab_svn_rev = True
97 self.deps_os = None 124 self.deps_os = None
98 self.force = force 125 self.force = force
99 self.reset = False 126 self.reset = False
100 self.nohooks = False 127 self.nohooks = False
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 1610
1584 if __name__ == '__main__': 1611 if __name__ == '__main__':
1585 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL 1612 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL
1586 logging.basicConfig( 1613 logging.basicConfig(
1587 level=level, 1614 level=level,
1588 format='%(asctime).19s %(levelname)s %(filename)s:' 1615 format='%(asctime).19s %(levelname)s %(filename)s:'
1589 '%(lineno)s %(message)s') 1616 '%(lineno)s %(message)s')
1590 unittest.main() 1617 unittest.main()
1591 1618
1592 # vim: ts=2:sw=2:tw=80:et: 1619 # 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