| 1 |
|
| 2 |
""" |
| 3 |
Usage: checkmodule.py <module-name> |
| 4 |
|
| 5 |
Check annotation and rtyping of the PyPy extension module from |
| 6 |
pypy/module/<module-name>/. Useful for testing whether a |
| 7 |
modules compiles without doing a full translation. |
| 8 |
""" |
| 9 |
import sys, os |
| 10 |
|
| 11 |
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) |
| 12 |
|
| 13 |
from pypy.objspace.fake.checkmodule import checkmodule |
| 14 |
|
| 15 |
def main(argv): |
| 16 |
if len(argv) != 2: |
| 17 |
print >> sys.stderr, __doc__ |
| 18 |
sys.exit(2) |
| 19 |
modname = argv[1] |
| 20 |
if modname in ('-h', '--help'): |
| 21 |
print >> sys.stderr, __doc__ |
| 22 |
sys.exit(0) |
| 23 |
if modname.startswith('-'): |
| 24 |
print >> sys.stderr, "Bad command line" |
| 25 |
print >> sys.stderr, __doc__ |
| 26 |
sys.exit(1) |
| 27 |
if os.path.sep in modname: |
| 28 |
if os.path.basename(modname) == '': |
| 29 |
modname = os.path.dirname(modname) |
| 30 |
if os.path.basename(os.path.dirname(modname)) != 'module': |
| 31 |
print >> sys.stderr, "Must give '../module/xxx', or just 'xxx'." |
| 32 |
sys.exit(1) |
| 33 |
modname = os.path.basename(modname) |
| 34 |
try: |
| 35 |
checkmodule(modname) |
| 36 |
except Exception: |
| 37 |
import traceback, pdb |
| 38 |
traceback.print_exc() |
| 39 |
pdb.post_mortem(sys.exc_info()[2]) |
| 40 |
return 1 |
| 41 |
else: |
| 42 |
print 'Passed.' |
| 43 |
return 0 |
| 44 |
|
| 45 |
if __name__ == '__main__': |
| 46 |
sys.exit(main(sys.argv)) |