##// END OF EJS Templates
test-nointerrupt: make "sure" the handler "might" trigger (issue6558)...
marmoute -
r48605:8892f604 stable
parent child Browse files
Show More
@@ -1,91 +1,94 b''
1 1 #require no-windows no-rhg
2 2
3 3 XXX-RHG this test hangs if `hg` is really `rhg`. This was hidden by the use of
4 4 `alias hg=rhg` by run-tests.py. With such alias removed, this test is revealed
5 5 buggy. This need to be resolved sooner than later.
6 6
7 7 Dummy extension simulating unsafe long running command
8 8 $ SYNC_FILE="$TESTTMP/sync-file"
9 9 $ export SYNC_FILE
10 10 $ DONE_FILE="$TESTTMP/done-file"
11 11 $ export DONE_FILE
12 12 $
13 13 $ cat > wait_ext.py <<EOF
14 14 > import os
15 15 > import time
16 16 >
17 17 > from mercurial.i18n import _
18 18 > from mercurial import registrar
19 19 > from mercurial import testing
20 20 >
21 21 > cmdtable = {}
22 22 > command = registrar.command(cmdtable)
23 23 >
24 24 > @command(b'wait-signal', [], _(b'SYNC_FILE DONE_FILE'), norepo=True)
25 25 > def sleep(ui, sync_file=b"$SYNC_FILE", done_file=b"$DONE_FILE", **opts):
26 26 > start = time.time()
27 27 > with ui.uninterruptible():
28 28 > testing.write_file(sync_file, b'%d' % os.getpid())
29 29 > testing.wait_file(done_file)
30 > # make sure we get rescheduled and the signal get a chance to be handled
31 > time.sleep(0.1)
30 32 > ui.warn(b"end of unsafe operation\n")
31 33 > ui.warn(b"%d second(s) passed\n" % int(time.time() - start))
32 34 > EOF
33 35
34 36 $ cat > send-signal.sh << EOF
35 37 > #!/bin/sh
36 38 > SIG=\$1
37 39 > if [ -z "\$SIG" ]; then
38 40 > echo "send-signal.sh requires one argument" >&2
39 41 > exit 1
40 42 > fi
41 43 > "$RUNTESTDIR/testlib/wait-on-file" 10 "$SYNC_FILE" || exit 2
42 44 > kill -s \$SIG \`cat "$SYNC_FILE"\`
45 > sleep 1
43 46 > touch "$DONE_FILE"
44 47 > EOF
45 48
46 49 #if no-windows
47 50 $ chmod +x send-signal.sh
48 51 #endif
49 52
50 53 Kludge to emulate timeout(1) which is not generally available.
51 54
52 55 Set up repository
53 56 $ hg init repo
54 57 $ cd repo
55 58 $ cat >> $HGRCPATH << EOF
56 59 > [extensions]
57 60 > wait_ext = $TESTTMP/wait_ext.py
58 61 > EOF
59 62
60 63
61 64 Test ctrl-c
62 65 $ rm -f $SYNC_FILE $DONE_FILE
63 66 $ sh -c "../send-signal.sh INT" &
64 67 $ hg wait-signal
65 68 interrupted!
66 69 [255]
67 70
68 71 $ cat >> $HGRCPATH << EOF
69 72 > [experimental]
70 73 > nointerrupt = yes
71 74 > EOF
72 75
73 76 $ rm -f $SYNC_FILE $DONE_FILE
74 77 $ sh -c "../send-signal.sh INT" &
75 78 $ hg wait-signal
76 79 interrupted!
77 80 [255]
78 81
79 82 $ cat >> $HGRCPATH << EOF
80 83 > [experimental]
81 84 > nointerrupt-interactiveonly = False
82 85 > EOF
83 86
84 87 $ rm -f $SYNC_FILE $DONE_FILE
85 88 $ sh -c "../send-signal.sh INT" &
86 89 $ hg wait-signal
87 90 shutting down cleanly
88 91 press ^C again to terminate immediately (dangerous)
89 92 end of unsafe operation
90 93 interrupted!
91 94 [255]
General Comments 0
You need to be logged in to leave comments. Login now