OLD | NEW |
---|---|
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 return items | 196 return items |
197 | 197 |
198 def testAutofix(self): | 198 def testAutofix(self): |
199 # Invalid urls causes pain when specifying requirements. Make sure it's | 199 # Invalid urls causes pain when specifying requirements. Make sure it's |
200 # auto-fixed. | 200 # auto-fixed. |
201 d = gclient.Dependency( | 201 d = gclient.Dependency( |
202 None, 'name', 'proto://host/path/@revision', None, None, | 202 None, 'name', 'proto://host/path/@revision', None, None, |
203 None, '', True) | 203 None, '', True) |
204 self.assertEquals('proto://host/path@revision', d.url) | 204 self.assertEquals('proto://host/path@revision', d.url) |
205 | 205 |
206 def testStr(self): | |
207 parser = gclient.Parser() | |
208 options, args = parser.parse_args([]) | |
209 write( | |
210 '.gclient', | |
211 'solutions = [\n' | |
212 ' { "name": "foo", "url": "svn://example.com/foo" },\n' | |
213 ' { "name": "bar", "url": "svn://example.com/bar" },\n' | |
214 ' { "name": "bar/empty", "url": "svn://example.com/bar_empty" },\n' | |
215 ']') | |
216 write( | |
217 os.path.join('foo', 'DEPS'), | |
218 'deps = {\n' | |
219 ' "foo/dir1": "/dir1",\n' | |
220 # This one will depend on dir1/dir2 in bar. | |
221 ' "foo/dir1/dir2/dir3": "/dir1/dir2/dir3",\n' | |
222 ' "foo/dir1/dir2/dir3/dir4": "/dir1/dir2/dir3/dir4",\n' | |
223 ' "foo/dir1/dir2/dir5/dir6":\n' | |
224 ' From("foo/dir1/dir2/dir3/dir4", "foo/dir1/dir2"),\n' | |
225 '}') | |
226 write( | |
227 os.path.join('bar', 'DEPS'), | |
228 'deps = {\n' | |
229 ' "foo/dir1/dir2": "/dir1/dir2",\n' | |
230 '}') | |
231 write( | |
232 os.path.join('bar/empty', 'DEPS'), | |
233 'deps = {\n' | |
234 '}') | |
235 # Test From() | |
236 write( | |
237 os.path.join('foo/dir1/dir2/dir3/dir4', 'DEPS'), | |
238 'deps = {\n' | |
239 # This one should not be fetched or set as a requirement. | |
240 ' "foo/dir1/dir2/dir5": "svn://example.com/x",\n' | |
241 ' "foo/dir1/dir2": "/dir1/another",\n' | |
242 '}') | |
243 | |
244 obj = gclient.GClient.LoadCurrentConfig(options) | |
245 obj.RunOnDeps('None', args) | |
246 self.assertEquals( | |
247 [ 'svn://example.com/foo', 'svn://example.com/bar', | |
248 'svn://example.com/bar_empty', 'svn://example.com/foo/dir1', | |
249 'svn://example.com/bar/dir1/dir2', | |
250 'svn://example.com/foo/dir1/dir2/dir3', | |
251 'svn://example.com/foo/dir1/dir2/dir3/dir4', | |
252 'svn://example.com/foo/dir1/dir2/dir3/dir4/dir1/another'], | |
253 self._get_processed()) | |
254 # Inject file_list manually. | |
255 obj.dependencies[0]._file_list.append('foo') # pylint: disable=W0212 | |
256 self.assertEquals(1874, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) | |
M-A Ruel
2011/09/14 22:56:55
The whole code above is to test this line.
| |
257 | |
258 | |
206 if __name__ == '__main__': | 259 if __name__ == '__main__': |
207 logging.basicConfig( | 260 logging.basicConfig( |
208 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 261 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
209 min(sys.argv.count('-v'), 3)], | 262 min(sys.argv.count('-v'), 3)], |
210 format='%(asctime).19s %(levelname)s %(filename)s:' | 263 format='%(asctime).19s %(levelname)s %(filename)s:' |
211 '%(lineno)s %(message)s') | 264 '%(lineno)s %(message)s') |
212 unittest.main() | 265 unittest.main() |
OLD | NEW |