##// END OF EJS Templates
tests: properly sort imports in test-nointerrupt.t...
Augie Fackler -
r38678:531f5e93 default
parent child Browse files
Show More
@@ -1,83 +1,83 b''
1 Dummy extension simulating unsafe long running command
1 Dummy extension simulating unsafe long running command
2 $ cat > sleepext.py <<EOF
2 $ cat > sleepext.py <<EOF
3 > import itertools
3 > import time
4 > import time
4 > import itertools
5 >
5 >
6 > from mercurial.i18n import _
6 > from mercurial import registrar
7 > from mercurial import registrar
7 > from mercurial.i18n import _
8 >
8 >
9 > cmdtable = {}
9 > cmdtable = {}
10 > command = registrar.command(cmdtable)
10 > command = registrar.command(cmdtable)
11 >
11 >
12 > @command(b'sleep', [], _(b'TIME'), norepo=True)
12 > @command(b'sleep', [], _(b'TIME'), norepo=True)
13 > def sleep(ui, sleeptime=b"1", **opts):
13 > def sleep(ui, sleeptime=b"1", **opts):
14 > with ui.uninterruptable():
14 > with ui.uninterruptable():
15 > for _i in itertools.repeat(None, int(sleeptime)):
15 > for _i in itertools.repeat(None, int(sleeptime)):
16 > time.sleep(1)
16 > time.sleep(1)
17 > ui.warn(b"end of unsafe operation\n")
17 > ui.warn(b"end of unsafe operation\n")
18 > ui.warn(b"%s second(s) passed\n" % sleeptime)
18 > ui.warn(b"%s second(s) passed\n" % sleeptime)
19 > EOF
19 > EOF
20
20
21 Kludge to emulate timeout(1) which is not generally available.
21 Kludge to emulate timeout(1) which is not generally available.
22 $ cat > timeout.py <<EOF
22 $ cat > timeout.py <<EOF
23 > from __future__ import print_function
23 > from __future__ import print_function
24 > import argparse
24 > import argparse
25 > import signal
25 > import signal
26 > import subprocess
26 > import subprocess
27 > import sys
27 > import sys
28 > import time
28 > import time
29 >
29 >
30 > ap = argparse.ArgumentParser()
30 > ap = argparse.ArgumentParser()
31 > ap.add_argument('-s', nargs=1, default='SIGTERM')
31 > ap.add_argument('-s', nargs=1, default='SIGTERM')
32 > ap.add_argument('duration', nargs=1, type=int)
32 > ap.add_argument('duration', nargs=1, type=int)
33 > ap.add_argument('argv', nargs='*')
33 > ap.add_argument('argv', nargs='*')
34 > opts = ap.parse_args()
34 > opts = ap.parse_args()
35 > try:
35 > try:
36 > sig = int(opts.s[0])
36 > sig = int(opts.s[0])
37 > except ValueError:
37 > except ValueError:
38 > sname = opts.s[0]
38 > sname = opts.s[0]
39 > if not sname.startswith('SIG'):
39 > if not sname.startswith('SIG'):
40 > sname = 'SIG' + sname
40 > sname = 'SIG' + sname
41 > sig = getattr(signal, sname)
41 > sig = getattr(signal, sname)
42 > proc = subprocess.Popen(opts.argv)
42 > proc = subprocess.Popen(opts.argv)
43 > time.sleep(opts.duration[0])
43 > time.sleep(opts.duration[0])
44 > proc.poll()
44 > proc.poll()
45 > if proc.returncode is None:
45 > if proc.returncode is None:
46 > proc.send_signal(sig)
46 > proc.send_signal(sig)
47 > proc.wait()
47 > proc.wait()
48 > sys.exit(124)
48 > sys.exit(124)
49 > EOF
49 > EOF
50
50
51 Set up repository
51 Set up repository
52 $ hg init repo
52 $ hg init repo
53 $ cd repo
53 $ cd repo
54 $ cat >> $HGRCPATH << EOF
54 $ cat >> $HGRCPATH << EOF
55 > [extensions]
55 > [extensions]
56 > sleepext = ../sleepext.py
56 > sleepext = ../sleepext.py
57 > EOF
57 > EOF
58
58
59 Test ctrl-c
59 Test ctrl-c
60 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
60 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
61 interrupted!
61 interrupted!
62 [124]
62 [124]
63
63
64 $ cat >> $HGRCPATH << EOF
64 $ cat >> $HGRCPATH << EOF
65 > [experimental]
65 > [experimental]
66 > nointerrupt = yes
66 > nointerrupt = yes
67 > EOF
67 > EOF
68
68
69 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
69 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
70 interrupted!
70 interrupted!
71 [124]
71 [124]
72
72
73 $ cat >> $HGRCPATH << EOF
73 $ cat >> $HGRCPATH << EOF
74 > [experimental]
74 > [experimental]
75 > nointerrupt-interactiveonly = False
75 > nointerrupt-interactiveonly = False
76 > EOF
76 > EOF
77
77
78 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
78 $ python $TESTTMP/timeout.py -s INT 1 hg sleep 2
79 shutting down cleanly
79 shutting down cleanly
80 press ^C again to terminate immediately (dangerous)
80 press ^C again to terminate immediately (dangerous)
81 end of unsafe operation
81 end of unsafe operation
82 interrupted!
82 interrupted!
83 [124]
83 [124]
General Comments 0
You need to be logged in to leave comments. Login now