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