regrtest.py :  » Language-Interface » ChinesePython » chinesepython2.1.3-0.4 » Tools » compiler » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » ChinesePython 
ChinesePython » chinesepython2.1.3 0.4 » Tools » compiler » regrtest.py
"""Run the Python regression test using the compiler

This test runs the standard Python test suite using bytecode generated
by this compiler instead of by the builtin compiler.

The regression test is run with the interpreter in verbose mode so
that import problems can be observed easily.
"""

from compiler import compile

import os
import sys
import test
import tempfile

def copy_test_suite():
    dest = tempfile.mktemp()
    os.mkdir(dest)
    os.system("cp -r %s/* %s" % (test.__path__[0], dest))
    print "Creating copy of test suite in", dest
    return dest

def copy_library():
    dest = tempfile.mktemp()
    os.mkdir(dest)
    libdir = os.path.split(test.__path__[0])[0]
    print "Found standard library in", libdir
    print "Creating copy of standard library in", dest
    os.system("cp -r %s/* %s" % (libdir, dest))
    return dest

def compile_files(dir):
    print "Compiling", dir, "\n\t",
    line_len = 10
    for file in os.listdir(dir):
        base, ext = os.path.splitext(file)
        if ext == '.py':
            source = os.path.join(dir, file)
            line_len = line_len + len(file) + 1
            if line_len > 75:
                print "\n\t",
                line_len = len(source) + 9
            print file,
            try:
                compile(source)
            except SyntaxError, err:
                print err
                continue
            # make sure the .pyc file is not over-written
            os.chmod(source + "c", 444)
        else:
            path = os.path.join(dir, file)
            if os.path.isdir(path):
                print
                print
                compile_files(path)
                print "\t",
                line_len = 10
    print

def run_regrtest(lib_dir):
    test_dir = os.path.join(lib_dir, "test")
    os.chdir(test_dir)
    os.system("PYTHONPATH=%s %s -v regrtest.py" % (lib_dir, sys.executable))

def cleanup(dir):
    os.system("rm -rf %s" % dir)

def main():
    lib_dir = copy_library()
    compile_files(lib_dir)
    run_regrtest(lib_dir)
    raw_input("Cleanup?")
    cleanup(lib_dir)

if __name__ == "__main__":
    main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.