File: checkmodule.py

package info (click to toggle)
pypy3 7.3.11%2Bdfsg-2%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 201,024 kB
  • sloc: python: 1,950,308; ansic: 517,580; sh: 21,417; asm: 14,419; cpp: 4,263; makefile: 4,228; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 11; awk: 4
file content (46 lines) | stat: -rwxr-xr-x 1,356 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
"""
Usage:  checkmodule.py <module-name>

Check annotation and rtyping of the PyPy extension module from
pypy/module/<module-name>/.  Useful for testing whether a
modules compiles without doing a full translation.
"""
import sys, os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))

from pypy.objspace.fake.checkmodule import checkmodule

def main(argv):
    if len(argv) != 2:
        print >> sys.stderr, __doc__
        sys.exit(2)
    modname = argv[1]
    if modname in ('-h', '--help'):
        print >> sys.stderr, __doc__
        sys.exit(0)
    if modname.startswith('-'):
        print >> sys.stderr, "Bad command line"
        print >> sys.stderr, __doc__
        sys.exit(1)
    if os.path.sep in modname:
        if os.path.basename(modname) == '':
            modname = os.path.dirname(modname)
        if os.path.basename(os.path.dirname(modname)) != 'module':
            print >> sys.stderr, "Must give '../module/xxx', or just 'xxx'."
            sys.exit(1)
        modname = os.path.basename(modname)
    try:
        checkmodule(modname)
    except Exception:
        import traceback, pdb
        traceback.print_exc()
        pdb.post_mortem(sys.exc_info()[2])
        return 1
    else:
        print 'Passed.'
        return 0

if __name__ == '__main__':
    sys.exit(main(sys.argv))