comparison tests/test-commandserver.t @ 37220:7f78de1c93aa

procutil: redirect ui.fout to stderr while stdio is protected The new behavior seems slightly nicer as we can at least read the output. And this is similar to what the sshserver is doing, so we can probably reuse protectstdio() instead of the weird hook.redirect(True) hack.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 25 Mar 2018 12:15:33 +0900
parents 5890e5872f36
children 6282c1965f8e
comparison
equal deleted inserted replaced
37219:ac71cbad5da3 37220:7f78de1c93aa
247 ... 'hooks.pre-identify=python:hook.hook', 247 ... 'hooks.pre-identify=python:hook.hook',
248 ... 'id'], 248 ... 'id'],
249 ... input=stringio('some input')) 249 ... input=stringio('some input'))
250 *** runcommand --config hooks.pre-identify=python:hook.hook id 250 *** runcommand --config hooks.pre-identify=python:hook.hook id
251 eff892de26ec tip 251 eff892de26ec tip
252 hook talking
253 now try to read something: ''
252 254
253 Clean hook cached version 255 Clean hook cached version
254 $ rm hook.py* 256 $ rm hook.py*
255 $ rm -Rf __pycache__ 257 $ rm -Rf __pycache__
256 258
617 > def debugreadstdin(ui): 619 > def debugreadstdin(ui):
618 > ui.write("read: %r\n" % sys.stdin.read(1)) 620 > ui.write("read: %r\n" % sys.stdin.read(1))
619 > @command(b"debugwritestdout", norepo=True) 621 > @command(b"debugwritestdout", norepo=True)
620 > def debugwritestdout(ui): 622 > def debugwritestdout(ui):
621 > os.write(1, "low-level stdout fd and\n") 623 > os.write(1, "low-level stdout fd and\n")
622 > sys.stdout.write("stdout should be redirected to /dev/null\n") 624 > sys.stdout.write("stdout should be redirected to stderr\n")
623 > sys.stdout.flush() 625 > sys.stdout.flush()
624 > EOF 626 > EOF
625 $ cat <<EOF >> .hg/hgrc 627 $ cat <<EOF >> .hg/hgrc
626 > [extensions] 628 > [extensions]
627 > dbgui = dbgui.py 629 > dbgui = dbgui.py
655 *** runcommand debugprompt --config ui.interactive=True 657 *** runcommand debugprompt --config ui.interactive=True
656 prompt: 5678 658 prompt: 5678
657 *** runcommand debugreadstdin 659 *** runcommand debugreadstdin
658 read: '' 660 read: ''
659 *** runcommand debugwritestdout 661 *** runcommand debugwritestdout
662 low-level stdout fd and
663 stdout should be redirected to stderr
660 664
661 665
662 run commandserver in commandserver, which is silly but should work: 666 run commandserver in commandserver, which is silly but should work:
663 667
664 >>> from __future__ import print_function 668 >>> from __future__ import print_function