tests/test-commandserver.t
changeset 45057 d6e99a446eea
parent 44373 98c14f0108b8
child 45765 ed84a4d48910
equal deleted inserted replaced
45056:9694895749ad 45057:d6e99a446eea
   732   abort: repository ../nonexistent not found!
   732   abort: repository ../nonexistent not found!
   733   [255]
   733   [255]
   734   $ cd ..
   734   $ cd ..
   735 
   735 
   736 
   736 
       
   737 #if no-windows
       
   738 
       
   739 option to not shutdown on SIGINT:
       
   740 
       
   741   $ cat <<'EOF' > dbgint.py
       
   742   > import os
       
   743   > import signal
       
   744   > import time
       
   745   > from mercurial import commands, registrar
       
   746   > cmdtable = {}
       
   747   > command = registrar.command(cmdtable)
       
   748   > @command(b"debugsleep", norepo=True)
       
   749   > def debugsleep(ui):
       
   750   >     time.sleep(1)
       
   751   > @command(b"debugsuicide", norepo=True)
       
   752   > def debugsuicide(ui):
       
   753   >     os.kill(os.getpid(), signal.SIGINT)
       
   754   >     time.sleep(1)
       
   755   > EOF
       
   756 
       
   757   >>> import signal
       
   758   >>> import time
       
   759   >>> from hgclient import checkwith, readchannel, runcommand
       
   760   >>> @checkwith(extraargs=[b'--config', b'cmdserver.shutdown-on-interrupt=False',
       
   761   ...                       b'--config', b'extensions.dbgint=dbgint.py'])
       
   762   ... def nointr(server):
       
   763   ...     readchannel(server)
       
   764   ...     server.send_signal(signal.SIGINT)  # server won't be terminated
       
   765   ...     time.sleep(1)
       
   766   ...     runcommand(server, [b'debugsleep'])
       
   767   ...     server.send_signal(signal.SIGINT)  # server won't be terminated
       
   768   ...     runcommand(server, [b'debugsleep'])
       
   769   ...     runcommand(server, [b'debugsuicide'])  # command can be interrupted
       
   770   ...     server.send_signal(signal.SIGTERM)  # server will be terminated
       
   771   ...     time.sleep(1)
       
   772   *** runcommand debugsleep
       
   773   *** runcommand debugsleep
       
   774   *** runcommand debugsuicide
       
   775   interrupted!
       
   776   killed!
       
   777    [255]
       
   778 
       
   779 #endif
       
   780 
       
   781 
   737 structured message channel:
   782 structured message channel:
   738 
   783 
   739   $ cat <<'EOF' >> repo2/.hg/hgrc
   784   $ cat <<'EOF' >> repo2/.hg/hgrc
   740   > [ui]
   785   > [ui]
   741   > # server --config should precede repository option
   786   > # server --config should precede repository option