Chromium Code Reviews| Index: tests/gclient_test.py |
| =================================================================== |
| --- tests/gclient_test.py (revision 126259) |
| +++ tests/gclient_test.py (working copy) |
| @@ -12,7 +12,9 @@ |
| import Queue |
| import logging |
| import os |
| +import shutil |
| import sys |
| +from tempfile import mkdtemp |
| import unittest |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| @@ -246,7 +248,40 @@ |
| str_obj = str(obj) |
| self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj)) |
| + def testHooks(self): |
|
M-A Ruel
2012/03/12 23:52:06
Use self.root_dir, trial_dir.TestCase already mana
szager
2012/03/13 00:00:18
Done.
|
| + topdir = mkdtemp() |
| + gclient_fn = os.path.join(topdir, '.gclient') |
| + fh = open(gclient_fn, 'w') |
| + print >> fh, 'solutions = [{"name":"top","url":"svn://svn.top.com/top"}]' |
| + fh.close() |
| + subdir_fn = os.path.join(topdir, 'top') |
| + os.mkdir(subdir_fn) |
| + deps_fn = os.path.join(subdir_fn, 'DEPS') |
| + fh = open(deps_fn, 'w') |
| + hooks = [{'pattern':'.', 'action':['cmd1', 'arg1', 'arg2']}] |
| + print >> fh, 'hooks = %s' % repr(hooks) |
| + fh.close() |
| + |
| + fh = open(os.path.join(subdir_fn, 'fake.txt'), 'w') |
| + print >> fh, 'bogus content' |
| + fh.close() |
| + |
| + os.chdir(topdir) |
| + |
| + parser = gclient.Parser() |
| + options, _ = parser.parse_args([]) |
| + options.force = True |
| + client = gclient.GClient.LoadCurrentConfig(options) |
| + work_queue = gclient_utils.ExecutionQueue(options.jobs, None) |
| + for s in client.dependencies: |
| + work_queue.enqueue(s) |
| + work_queue.flush({}, None, [], options=options) |
| + self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks]) |
| + |
| + shutil.rmtree(topdir) |
| + |
| + |
| if __name__ == '__main__': |
| sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
| sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |