view contrib/check-config.py @ 27396:64c584070fc7

run-tests: show scheduling with --showchannels This gives one line of output per second with one column per -j level that allows analyzing test scheduling problems. First 24 seconds of output at -j 30 looks like this: 0 . 1 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = s. 2 c c o c r l g r s s = c p = c h c a h c g c h c b c c l l c ss 3 h o b o e a e u u u c o a h o e o c g o l h g h u o = a o = s 4 e n s n b r n n b b m t g n l n l w n o e w e n n e r g i . 5 c t o = a g d - r r = m c w v p v . e v g c e c d v x g . m 6 k r l r s e o t e e b a h e e . e . b e . k b k l e t e . p 7 - i e e e f c e p p u n b b r . r . - r . - - - e r e f . o . 8 p b t v - i . s o o n d o d t . t . c t . c s = 2 t n i . r 9 y - e s c l . t - . d - m i - . - . o - . o y r - - s l . t 10 3 p - e h e . s s . l t b r s . s . m s . d m e f s i e . . 11 - e c t e s . . v . e e . . v . v . m v . e r n o v o s . . 12 c r h . c - . . n . 2 m . . n . n . a n . . e a r n n . . . 13 o f e . k u . . . . - p . . - . - . n - . . v m m - . . . . 14 m . c . - p . . . . e l . . s . m . d s . . . e a e . . . . 15 p . k . r d . . . . x a . . i . o . s o . . . - t n . . . . 16 a . h . e a . . . . c t . . n . v . . u . . . m . c . . . . 17 t . e . s t . . . . h e . . k . e . . r . . . e . o . . . . 18 . . a . t e . . . . a . . . . . . . . c . . . r . d . . . . 19 . . d . o . . . . . n . . . . . . . . e . . . g . i . . . . 20 . . s . r . . . . . g . . . . . . . . . . . . e . n . . . . 21 . . . . e . . . . . e . . . . . . . . . . . . 2 . g . . . . 22 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . ^C Test names read off vertically, beginning with '='. Idle time (not shown) appears as blank space.
author Matt Mackall <mpm@selenic.com>
date Mon, 07 Dec 2015 16:16:06 -0600
parents 9d155accd8f1
children 8f244b75cc5e
line wrap: on
line source

#!/usr/bin/env python
#
# check-config - a config flag documentation checker for Mercurial
#
# Copyright 2015 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import re
import sys

foundopts = {}
documented = {}

configre = (r"""ui\.config(|int|bool|list)\(['"](\S+)['"],\s*"""
            r"""['"](\S+)['"](,\s+(?:default=)?(\S+?))?\)""")
configpartialre = (r"""ui\.config""")

def main(args):
    for f in args:
        sect = ''
        prevname = ''
        confsect = ''
        carryover = ''
        for l in open(f):

            # check topic-like bits
            m = re.match('\s*``(\S+)``', l)
            if m:
                prevname = m.group(1)
            if re.match('^\s*-+$', l):
                sect = prevname
                prevname = ''

            if sect and prevname:
                name = sect + '.' + prevname
                documented[name] = 1

            # check docstring bits
            m = re.match(r'^\s+\[(\S+)\]', l)
            if m:
                confsect = m.group(1)
                continue
            m = re.match(r'^\s+(?:#\s*)?(\S+) = ', l)
            if m:
                name = confsect + '.' + m.group(1)
                documented[name] = 1

            # like the bugzilla extension
            m = re.match(r'^\s*(\S+\.\S+)$', l)
            if m:
                documented[m.group(1)] = 1

            # like convert
            m = re.match(r'^\s*:(\S+\.\S+):\s+', l)
            if m:
                documented[m.group(1)] = 1

            # quoted in help or docstrings
            m = re.match(r'.*?``(\S+\.\S+)``', l)
            if m:
                documented[m.group(1)] = 1

            # look for ignore markers
            m = re.search(r'# (?:internal|experimental|deprecated|developer)'
                          ' config: (\S+\.\S+)$', l)
            if m:
                documented[m.group(1)] = 1

            # look for code-like bits
            line = carryover + l
            m = re.search(configre, line, re.MULTILINE)
            if m:
                ctype = m.group(1)
                if not ctype:
                    ctype = 'str'
                name = m.group(2) + "." + m.group(3)
                default = m.group(5)
                if default in (None, 'False', 'None', '0', '[]', '""', "''"):
                    default = ''
                if re.match('[a-z.]+$', default):
                    default = '<variable>'
                if name in foundopts and (ctype, default) != foundopts[name]:
                    print l
                    print "conflict on %s: %r != %r" % (name, (ctype, default),
                                                        foundopts[name])
                foundopts[name] = (ctype, default)
                carryover = ''
            else:
                m = re.search(configpartialre, line)
                if m:
                    carryover = line
                else:
                    carryover = ''

    for name in sorted(foundopts):
        if name not in documented:
            if not (name.startswith("devel.") or
                    name.startswith("experimental.") or
                    name.startswith("debug.")):
                ctype, default = foundopts[name]
                if default:
                    default = ' [%s]' % default
                print "undocumented: %s (%s)%s" % (name, ctype, default)

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))