tests/test-commandserver.t
changeset 23324 69f86b937035
parent 23322 000cfc8b3913
child 23388 42ed0780ec4b
equal deleted inserted replaced
23323:bc374458688b 23324:69f86b937035
   490   patch queue now empty
   490   patch queue now empty
   491   *** runcommand qqueue --active
   491   *** runcommand qqueue --active
   492   foo
   492   foo
   493 
   493 
   494   $ cat <<EOF > dbgui.py
   494   $ cat <<EOF > dbgui.py
       
   495   > import os, sys
   495   > from mercurial import cmdutil, commands
   496   > from mercurial import cmdutil, commands
   496   > cmdtable = {}
   497   > cmdtable = {}
   497   > command = cmdutil.command(cmdtable)
   498   > command = cmdutil.command(cmdtable)
   498   > @command("debuggetpass", norepo=True)
   499   > @command("debuggetpass", norepo=True)
   499   > def debuggetpass(ui):
   500   > def debuggetpass(ui):
   500   >     ui.write("%s\\n" % ui.getpass())
   501   >     ui.write("%s\\n" % ui.getpass())
   501   > @command("debugprompt", norepo=True)
   502   > @command("debugprompt", norepo=True)
   502   > def debugprompt(ui):
   503   > def debugprompt(ui):
   503   >     ui.write("%s\\n" % ui.prompt("prompt:"))
   504   >     ui.write("%s\\n" % ui.prompt("prompt:"))
       
   505   > @command("debugreadstdin", norepo=True)
       
   506   > def debugreadstdin(ui):
       
   507   >     ui.write("read: %r\n" % sys.stdin.read(1))
       
   508   > @command("debugwritestdout", norepo=True)
       
   509   > def debugwritestdout(ui):
       
   510   >     os.write(1, "low-level stdout fd and\n")
       
   511   >     sys.stdout.write("stdout should be redirected to /dev/null\n")
       
   512   >     sys.stdout.flush()
   504   > EOF
   513   > EOF
   505   $ cat <<EOF >> .hg/hgrc
   514   $ cat <<EOF >> .hg/hgrc
   506   > [extensions]
   515   > [extensions]
   507   > dbgui = dbgui.py
   516   > dbgui = dbgui.py
   508   > EOF
   517   > EOF
   516   ...                         'ui.interactive=True'],
   525   ...                         'ui.interactive=True'],
   517   ...                input=cStringIO.StringIO('1234\n'))
   526   ...                input=cStringIO.StringIO('1234\n'))
   518   ...     runcommand(server, ['debugprompt', '--config',
   527   ...     runcommand(server, ['debugprompt', '--config',
   519   ...                         'ui.interactive=True'],
   528   ...                         'ui.interactive=True'],
   520   ...                input=cStringIO.StringIO('5678\n'))
   529   ...                input=cStringIO.StringIO('5678\n'))
       
   530   ...     runcommand(server, ['debugreadstdin'])
       
   531   ...     runcommand(server, ['debugwritestdout'])
   521   *** runcommand debuggetpass --config ui.interactive=True
   532   *** runcommand debuggetpass --config ui.interactive=True
   522   password: 1234
   533   password: 1234
   523   *** runcommand debugprompt --config ui.interactive=True
   534   *** runcommand debugprompt --config ui.interactive=True
   524   prompt: 5678
   535   prompt: 5678
       
   536   *** runcommand debugreadstdin
       
   537   read: ''
       
   538   *** runcommand debugwritestdout
   525 
   539 
   526 
   540 
   527 run commandserver in commandserver, which is silly but should work:
   541 run commandserver in commandserver, which is silly but should work:
   528 
   542 
   529   >>> import cStringIO
   543   >>> import cStringIO