diff tests/test-commandserver.py @ 14889:a59058fd074a stable

hooks: redirect stdout/err/in to the ui descriptors when calling python hooks We need to make sure that python hooks I/O goes through the ui descriptors so it doesn't mess the command server protocol.
author Idan Kamara <idankk86@gmail.com>
date Sat, 09 Jul 2011 19:06:59 +0300
parents bb2cffe81a94
children b4c06b97dfe0
line wrap: on
line diff
--- a/tests/test-commandserver.py	Fri Jul 15 20:07:19 2011 +0200
+++ b/tests/test-commandserver.py	Sat Jul 09 19:06:59 2011 +0300
@@ -144,6 +144,16 @@
     runcommand(server, ['-R', 'foo', 'showconfig'])
     shutil.rmtree('foo')
 
+def hook(**args):
+    print 'hook talking'
+    print 'now try to read something: %r' % sys.stdin.read()
+
+def hookoutput(server):
+    readchannel(server)
+    runcommand(server, ['--config',
+                        'hooks.pre-identify=python:test-commandserver.hook', 'id'],
+               input=cStringIO.StringIO('some input'))
+
 if __name__ == '__main__':
     os.system('hg init')
 
@@ -158,3 +168,4 @@
     hgrc.write('[ui]\nfoo=bar\n')
     hgrc.close()
     check(localhgrc)
+    check(hookoutput)