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 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 while True: | 209 while True: |
210 items.append(self.processed.get_nowait()) | 210 items.append(self.processed.get_nowait()) |
211 except Queue.Empty: | 211 except Queue.Empty: |
212 pass | 212 pass |
213 return items | 213 return items |
214 | 214 |
215 def testAutofix(self): | 215 def testAutofix(self): |
216 # Invalid urls causes pain when specifying requirements. Make sure it's | 216 # Invalid urls causes pain when specifying requirements. Make sure it's |
217 # auto-fixed. | 217 # auto-fixed. |
218 d = gclient.Dependency( | 218 d = gclient.Dependency( |
219 None, 'name', 'proto://host/path/@revision', None, None, None, None, | 219 None, 'name', 'proto://host/path/@revision', None, None, None, |
220 None, '', True) | 220 None, '', True) |
221 self.assertEquals('proto://host/path@revision', d.url) | 221 self.assertEquals('proto://host/path@revision', d.url) |
222 | 222 |
223 def testStr(self): | 223 def testStr(self): |
224 parser = gclient.OptionParser() | 224 parser = gclient.OptionParser() |
225 options, _ = parser.parse_args([]) | 225 options, _ = parser.parse_args([]) |
226 obj = gclient.GClient('foo', options) | 226 obj = gclient.GClient('foo', options) |
227 obj.add_dependencies_and_close( | 227 obj.add_dependencies_and_close( |
228 [ | 228 [ |
229 gclient.Dependency( | 229 gclient.Dependency( |
230 obj, 'foo', 'url', None, None, None, None, None, 'DEPS', True), | 230 obj, 'foo', 'url', None, None, None, None, 'DEPS', True), |
231 gclient.Dependency( | 231 gclient.Dependency( |
232 obj, 'bar', 'url', None, None, None, None, None, 'DEPS', True), | 232 obj, 'bar', 'url', None, None, None, None, 'DEPS', True), |
233 ], | 233 ], |
234 []) | 234 []) |
235 obj.dependencies[0].add_dependencies_and_close( | 235 obj.dependencies[0].add_dependencies_and_close( |
236 [ | 236 [ |
237 gclient.Dependency( | 237 gclient.Dependency( |
238 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, | 238 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, |
239 None, 'DEPS', True), | 239 None, 'DEPS', True), |
240 gclient.Dependency( | 240 gclient.Dependency( |
241 obj.dependencies[0], 'foo/dir2', | 241 obj.dependencies[0], 'foo/dir2', |
242 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, | 242 gclient.GClientKeywords.FromImpl('bar'), None, None, None, |
243 None, 'DEPS', True), | 243 None, 'DEPS', True), |
244 gclient.Dependency( | 244 gclient.Dependency( |
245 obj.dependencies[0], 'foo/dir3', | 245 obj.dependencies[0], 'foo/dir3', |
246 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, | 246 gclient.GClientKeywords.FileImpl('url'), None, None, None, |
247 None, 'DEPS', True), | 247 None, 'DEPS', True), |
248 ], | 248 ], |
249 []) | 249 []) |
250 # Make sure __str__() works fine. | 250 # Make sure __str__() works fine. |
251 # pylint: disable=W0212 | 251 # pylint: disable=W0212 |
252 obj.dependencies[0]._file_list.append('foo') | 252 obj.dependencies[0]._file_list.append('foo') |
253 str_obj = str(obj) | 253 str_obj = str(obj) |
254 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj)) | 254 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj)) |
255 | 255 |
256 def testHooks(self): | 256 def testHooks(self): |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 orig_deps = copy.deepcopy(deps) | 557 orig_deps = copy.deepcopy(deps) |
558 result = gclient.Dependency.MergeWithOsDeps(deps, deps_os, target_os_list) | 558 result = gclient.Dependency.MergeWithOsDeps(deps, deps_os, target_os_list) |
559 self.assertEqual(result, expected_deps) | 559 self.assertEqual(result, expected_deps) |
560 self.assertEqual(deps, orig_deps) | 560 self.assertEqual(deps, orig_deps) |
561 | 561 |
562 | 562 |
563 def testLateOverride(self): | 563 def testLateOverride(self): |
564 """Verifies expected behavior of LateOverride.""" | 564 """Verifies expected behavior of LateOverride.""" |
565 url = "git@github.com:dart-lang/spark.git" | 565 url = "git@github.com:dart-lang/spark.git" |
566 d = gclient.Dependency(None, 'name', 'url', | 566 d = gclient.Dependency(None, 'name', 'url', |
567 None, None, None, None, None, '', True) | 567 None, None, None, None, '', True) |
568 late_url = d.LateOverride(url) | 568 late_url = d.LateOverride(url) |
569 self.assertEquals(url, late_url) | 569 self.assertEquals(url, late_url) |
570 | 570 |
571 def testDepsOsOverrideDepsInDepsFile(self): | 571 def testDepsOsOverrideDepsInDepsFile(self): |
572 """Verifies that a 'deps_os' path can override a 'deps' path. Also | 572 """Verifies that a 'deps_os' path can override a 'deps' path. Also |
573 see testUpdateWithOsDeps above. | 573 see testUpdateWithOsDeps above. |
574 """ | 574 """ |
575 | 575 |
576 write( | 576 write( |
577 '.gclient', | 577 '.gclient', |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 1066 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
1067 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 1067 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
1068 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 1068 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
1069 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 1069 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
1070 logging.basicConfig( | 1070 logging.basicConfig( |
1071 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 1071 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
1072 min(sys.argv.count('-v'), 3)], | 1072 min(sys.argv.count('-v'), 3)], |
1073 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 1073 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
1074 '%(lineno)d) %(message)s') | 1074 '%(lineno)d) %(message)s') |
1075 unittest.main() | 1075 unittest.main() |
OLD | NEW |