author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 12 Jul 2021 00:14:11 +0200 | |
changeset 47615 | a8d1adeeba87 |
parent 47587 | be496e3489b9 |
child 47762 | f48a688a7044 |
permissions | -rw-r--r-- |
47587
be496e3489b9
tests: blacklist a handful of test with `rhg` or `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47063
diff
changeset
|
1 |
#require no-windows no-rhg |
be496e3489b9
tests: blacklist a handful of test with `rhg` or `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47063
diff
changeset
|
2 |
|
be496e3489b9
tests: blacklist a handful of test with `rhg` or `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47063
diff
changeset
|
3 |
XXX-RHG this test hangs if `hg` is really `rhg`. This was hidden by the use of |
be496e3489b9
tests: blacklist a handful of test with `rhg` or `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47063
diff
changeset
|
4 |
`alias hg=rhg` by run-tests.py. With such alias removed, this test is revealed |
be496e3489b9
tests: blacklist a handful of test with `rhg` or `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47063
diff
changeset
|
5 |
buggy. This need to be resolved sooner than later. |
39479
3ba87d5b9ad3
tests: disable test-nointerrupt on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
38656
diff
changeset
|
6 |
|
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
Dummy extension simulating unsafe long running command |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
$ cat > sleepext.py <<EOF |
38656
531f5e933e49
tests: properly sort imports in test-nointerrupt.t
Augie Fackler <augie@google.com>
parents:
38526
diff
changeset
|
9 |
> import itertools |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
> import time |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
> |
38656
531f5e933e49
tests: properly sort imports in test-nointerrupt.t
Augie Fackler <augie@google.com>
parents:
38526
diff
changeset
|
12 |
> from mercurial.i18n import _ |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
> from mercurial import registrar |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
> |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
> cmdtable = {} |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
> command = registrar.command(cmdtable) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
> |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
> @command(b'sleep', [], _(b'TIME'), norepo=True) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
> def sleep(ui, sleeptime=b"1", **opts): |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
39479
diff
changeset
|
20 |
> with ui.uninterruptible(): |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
> for _i in itertools.repeat(None, int(sleeptime)): |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
> time.sleep(1) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
> ui.warn(b"end of unsafe operation\n") |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 |
> ui.warn(b"%s second(s) passed\n" % sleeptime) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 |
> EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
|
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
Kludge to emulate timeout(1) which is not generally available. |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
$ cat > timeout.py <<EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
> from __future__ import print_function |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 |
> import argparse |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
> import signal |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
> import subprocess |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
> import sys |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
> import time |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 |
> |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 |
> ap = argparse.ArgumentParser() |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
> ap.add_argument('-s', nargs=1, default='SIGTERM') |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 |
> ap.add_argument('duration', nargs=1, type=int) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
> ap.add_argument('argv', nargs='*') |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
> opts = ap.parse_args() |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 |
> try: |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 |
> sig = int(opts.s[0]) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 |
> except ValueError: |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
44 |
> sname = opts.s[0] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
> if not sname.startswith('SIG'): |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 |
> sname = 'SIG' + sname |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
> sig = getattr(signal, sname) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 |
> proc = subprocess.Popen(opts.argv) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
> time.sleep(opts.duration[0]) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
> proc.poll() |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 |
> if proc.returncode is None: |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
> proc.send_signal(sig) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 |
> proc.wait() |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 |
> sys.exit(124) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 |
> EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 |
|
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 |
Set up repository |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
58 |
$ hg init repo |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 |
$ cd repo |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 |
$ cat >> $HGRCPATH << EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 |
> [extensions] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 |
> sleepext = ../sleepext.py |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 |
> EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 |
|
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 |
Test ctrl-c |
47063
1d075b857c90
tests: ensure `$PYTHON` is quoted for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46226
diff
changeset
|
66 |
$ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2 |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 |
interrupted! |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 |
[124] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
|
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 |
$ cat >> $HGRCPATH << EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 |
> [experimental] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
72 |
> nointerrupt = yes |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
73 |
> EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 |
|
47063
1d075b857c90
tests: ensure `$PYTHON` is quoted for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46226
diff
changeset
|
75 |
$ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2 |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
76 |
interrupted! |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
77 |
[124] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 |
|
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
79 |
$ cat >> $HGRCPATH << EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 |
> [experimental] |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 |
> nointerrupt-interactiveonly = False |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 |
> EOF |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
|
47063
1d075b857c90
tests: ensure `$PYTHON` is quoted for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46226
diff
changeset
|
84 |
$ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2 |
38526
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 |
shutting down cleanly |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
press ^C again to terminate immediately (dangerous) |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
87 |
end of unsafe operation |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 |
interrupted! |
313a940d49a3
ui: add an uninterruptable context manager that can block SIGINT
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 |
[124] |