contrib/showstack.py
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 08 Feb 2016 18:29:17 +0900
changeset 28035 c65da6892ae5
parent 26123 bdac264e5ed4
child 28522 f2fe7b199bb4
permissions -rw-r--r--
tests: make chunk header of external diff glob-ed for portability Before this patch, some tests using external "diff" command via extdiff extension fail on Solaris, because system standard "diff" (= /usr/bin/diff) on Solaris always formats chunk header in the style below: @@ -X.x +Y.y @@ even though "diff" on Linux sometimes omits ".x" and/or ".y" in it. This patch makes chunk header of external diff glob-ed for portability of tests, and adds check-code.py rules to detect such diff output in tests. This patch also changes "hg diff" output in test-subrepo-git to simplify detection rules, even though it is certainly portable because these lines are generated by "git" command. This patch is a part of making tests using external "diff" portable, and tests below aren't yet portable even after this patch. test-largefiles-update.t test-subrepo-deep-nested-change.t
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26123
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
# showstack.py - extension to dump a Python stack trace on signal
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
#
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
import sys, signal, traceback
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
def sigshow(*args):
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
    sys.stderr.write("\n")
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
    traceback.print_stack(args[1], limit=10, file=sys.stderr)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
    sys.stderr.write("----\n")
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
def extsetup(ui):
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
    signal.signal(signal.SIGQUIT, sigshow)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
    try:
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
        signal.signal(signal.SIGINFO, sigshow)
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
    except AttributeError:
bdac264e5ed4 contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
        pass