Mercurial > hg
view contrib/showstack.py @ 46067:cc0b332ab9fc
run-tests: stuff a `python3.exe` into the test bin directory on Windows
Windows doesn't have `python3.exe` as part of the python.org distribution, and
that broke every script with a shebang after c102b704edb5. Windows itself
provides a `python3.exe` app execution alias[1], but it is some sort of reparse
point that MSYS is incapable of handling[2]. When run by MSYS, it simply prints
$ python3 -V
- Cannot open
That in turn caused every `hghave` check, and test that invokes shebang scripts
directly, to fail. Rather than try to patch up every script call to be invoked
with `$PYTHON` (and regress when non Windows developers forget), copying the
executable into the test binary directory with the new name just works. Since
this directory is prepended to the system PATH value, it also overrides the
broken execution alias. (The `_tmpbindir` is used instead of `_bindir` because
the latter causes python3.exe to be copied into the repo next to hg.exe when
`test-run-tests.t` runs. Something runs with this version of the executable and
subsequent runs of `run-tests.py` inside `test-run-tests.t` try to copy over it
while it is in use, and fail. This avoids the failures and the clutter.)
I didn't conditionalize this on py3 because `python3.exe` needs to be present
(for the shebangs) even when running py2 tests. It shouldn't matter to these
simple scripts, and I think the intention is to make the test runner use py3
always, even if testing a py2 build. For now, still supporting py2 is helping
to clean up the mess that is py3 tests.
[1] https://stackoverflow.com/a/57168165
[2] https://stackoverflow.com/questions/59148628/solved-unable-to-run-python-3-7-on-windows-10-permission-denied#comment104524397_59148666
Differential Revision: https://phab.mercurial-scm.org/D9543
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 07 Dec 2020 16:18:28 -0500 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
line wrap: on
line source
# showstack.py - extension to dump a Python stack trace on signal # # binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs) r"""dump stack trace when receiving SIGQUIT (Ctrl-\) or SIGINFO (Ctrl-T on BSDs) """ from __future__ import absolute_import, print_function import signal import sys import traceback def sigshow(*args): sys.stderr.write("\n") traceback.print_stack(args[1], limit=10, file=sys.stderr) sys.stderr.write("----\n") def sigexit(*args): sigshow(*args) print('alarm!') sys.exit(1) def extsetup(ui): signal.signal(signal.SIGQUIT, sigshow) signal.signal(signal.SIGALRM, sigexit) try: signal.signal(signal.SIGINFO, sigshow) except AttributeError: pass