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

Side by Side Diff: tests/gclient_test.py

Issue 8135019: Move all mutations into a specific place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: address review comments Created 9 years, 2 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 | « gclient.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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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.py. 6 """Unit tests for gclient.py.
7 7
8 See gclient_smoketest.py for integration tests. 8 See gclient_smoketest.py for integration tests.
9 """ 9 """
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 def testAutofix(self): 206 def testAutofix(self):
207 # Invalid urls causes pain when specifying requirements. Make sure it's 207 # Invalid urls causes pain when specifying requirements. Make sure it's
208 # auto-fixed. 208 # auto-fixed.
209 d = gclient.Dependency( 209 d = gclient.Dependency(
210 None, 'name', 'proto://host/path/@revision', None, None, None, 210 None, 'name', 'proto://host/path/@revision', None, None, None,
211 None, '', True) 211 None, '', True)
212 self.assertEquals('proto://host/path@revision', d.url) 212 self.assertEquals('proto://host/path@revision', d.url)
213 213
214 def testStr(self): 214 def testStr(self):
215 # Make sure __str__() works fine.
216 # pylint: disable=W0212
217 parser = gclient.Parser() 215 parser = gclient.Parser()
218 options, _ = parser.parse_args([]) 216 options, _ = parser.parse_args([])
219 obj = gclient.GClient('foo', options) 217 obj = gclient.GClient('foo', options)
220 obj._dependencies.append( 218 obj.add_dependencies_and_close(
221 gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS', 219 [
222 True)) 220 gclient.Dependency(
223 obj._dependencies.append( 221 obj, 'foo', 'url', None, None, None, None, 'DEPS', True),
224 gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS', 222 gclient.Dependency(
225 True)) 223 obj, 'bar', 'url', None, None, None, None, 'DEPS', True),
226 obj.dependencies[0]._dependencies.append( 224 ],
227 gclient.Dependency( 225 [])
228 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, 226 obj.dependencies[0].add_dependencies_and_close(
229 'DEPS', True)) 227 [
230 obj.dependencies[0]._dependencies.append( 228 gclient.Dependency(
231 gclient.Dependency( 229 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
232 obj.dependencies[0], 'foo/dir2', 230 'DEPS', True),
233 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, 231 gclient.Dependency(
234 'DEPS', True)) 232 obj.dependencies[0], 'foo/dir2',
235 obj.dependencies[0]._dependencies.append( 233 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
236 gclient.Dependency( 234 'DEPS', True),
237 obj.dependencies[0], 'foo/dir3', 235 gclient.Dependency(
238 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, 236 obj.dependencies[0], 'foo/dir3',
239 'DEPS', True)) 237 gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
238 'DEPS', True),
239 ],
240 [])
241 # Make sure __str__() works fine.
242 # pylint: disable=W0212
240 obj.dependencies[0]._file_list.append('foo') 243 obj.dependencies[0]._file_list.append('foo')
241 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) 244 str_obj = str(obj)
245 self.assertEquals(472, len(str_obj), '%d\n%s' % (len(str_obj), str_obj))
242 246
243 247
244 if __name__ == '__main__': 248 if __name__ == '__main__':
245 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 249 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
246 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 250 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
247 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 251 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
248 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 252 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
249 logging.basicConfig( 253 logging.basicConfig(
250 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 254 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
251 min(sys.argv.count('-v'), 3)], 255 min(sys.argv.count('-v'), 3)],
252 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 256 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
253 '%(lineno)d) %(message)s') 257 '%(lineno)d) %(message)s')
254 unittest.main() 258 unittest.main()
OLDNEW
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698