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

Side by Side Diff: tests/gclient_test.py

Issue 9232068: Added `gclient hookinfo`. This will be used to convert hooks into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 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 | « 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, 239 gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
240 'DEPS', True), 240 'DEPS', True),
241 ], 241 ],
242 []) 242 [])
243 # Make sure __str__() works fine. 243 # Make sure __str__() works fine.
244 # pylint: disable=W0212 244 # pylint: disable=W0212
245 obj.dependencies[0]._file_list.append('foo') 245 obj.dependencies[0]._file_list.append('foo')
246 str_obj = str(obj) 246 str_obj = str(obj)
247 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj)) 247 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj))
248 248
249 def testHooks(self):
250 topdir = self.root_dir
251 gclient_fn = os.path.join(topdir, '.gclient')
252 fh = open(gclient_fn, 'w')
253 print >> fh, 'solutions = [{"name":"top","url":"svn://svn.top.com/top"}]'
254 fh.close()
255 subdir_fn = os.path.join(topdir, 'top')
256 os.mkdir(subdir_fn)
257 deps_fn = os.path.join(subdir_fn, 'DEPS')
258 fh = open(deps_fn, 'w')
259 hooks = [{'pattern':'.', 'action':['cmd1', 'arg1', 'arg2']}]
260 print >> fh, 'hooks = %s' % repr(hooks)
261 fh.close()
262
263 fh = open(os.path.join(subdir_fn, 'fake.txt'), 'w')
264 print >> fh, 'bogus content'
265 fh.close()
266
267 os.chdir(topdir)
268
269 parser = gclient.Parser()
270 options, _ = parser.parse_args([])
271 options.force = True
272 client = gclient.GClient.LoadCurrentConfig(options)
273 work_queue = gclient_utils.ExecutionQueue(options.jobs, None)
274 for s in client.dependencies:
275 work_queue.enqueue(s)
276 work_queue.flush({}, None, [], options=options)
277 self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks])
278
249 279
250 if __name__ == '__main__': 280 if __name__ == '__main__':
251 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 281 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
252 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 282 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
253 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 283 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
254 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 284 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
255 logging.basicConfig( 285 logging.basicConfig(
256 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 286 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
257 min(sys.argv.count('-v'), 3)], 287 min(sys.argv.count('-v'), 3)],
258 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 288 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
259 '%(lineno)d) %(message)s') 289 '%(lineno)d) %(message)s')
260 unittest.main() 290 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