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