Changeset 491

Show
Ignore:
Timestamp:
Wed Jul 23 17:10:29 2008
Author:
htgoebel
Message:

Added option for not running the built executables (usefull for cross
builds). Added more files for cleaning. Some code cleanups.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/buildtests/runtests.py

    r488 r491  
    35 35         PYTHON='"%s"' % PYTHON  
    36 36  
      37 # files/globs to clean up  
      38 CLEANUP = """python_exe.build  
      39 logdict*.log  
      40 disttest*  
      41 buildtest*  
      42 warn*.txt  
      43 *.py[co]  
      44 */*.py[co]  
      45 */*/*.py[co]  
      46 """.split()  
      47  
    37 48 def clean():  
    38       distdirs = glob.glob('disttest*')  
    39       for dir in distdirs:  
    40           try:  
    41               shutil.rmtree(dir)  
    42           except OSError, e:  
    43               print e  
    44       builddirs = glob.glob('buildtest*')  
    45       for dir in builddirs:  
    46           try:  
    47               shutil.rmtree(dir)  
    48           except OSError, e:  
    49               print e  
    50       wfiles = glob.glob('warn*.txt')  
    51       for file in wfiles:  
    52           try:  
    53               os.remove(file)  
    54           except OSError, e:  
    55               print e  
      49     for clean in CLEANUP:  
      50         clean = glob.glob(clean)  
      51         for path in clean:  
      52             try:  
      53                 if os.path.isdir(path):  
      54                     shutil.rmtree(path)  
      55                 else:  
      56                     os.remove(path)  
      57             except OSError, e:  
      58                 print e  
      59  
      60  
      61 def _msg(*args, **kw):  
      62     short = kw.get('short', 0)  
      63     if not short: print  
      64     print "##################",  
      65     for a in args: print a,  
      66     print "#######################"  
      67     if not short: print  
      68  
    56 69  
    57   def runtests(alltests, filters=None):  
      70 def runtests(alltests, filters=None, run_executable=1):  
    57 70     info = "Executing PyInstaller tests in: %s" % os.getcwd()  
    58 71     print "*"*len(info)  
    59 72     print info  
    60 73     print "*"*len(info)  
      74  
    61 75     build_python = open("python_exe.build", "w")  
    62 76     build_python.write(sys.executable)  
     
    73 87     counter = dict(passed=[],failed=[])  
    74 88     for src in tests:  
    75           print  
    76           print "################## BUILDING TEST %s #################################" % src  
    77           print  
      89         _msg("BUILDING TEST", src)  
    78 90         test = os.path.splitext(os.path.basename(src))[0]  
    79           os.system('%s ../Build.py %s' % (PYTHON, test+".spec"))  
      91         res = os.system('%s ../Build.py %s' % (PYTHON, test+".spec"))  
    79 91         # Run the test in a clean environment to make sure they're really self-contained  
    80           del os.environ["PATH"]  
    81           print  
    82           print "################## EXECUTING TEST %s ################################" % src  
    83           print  
    84           res = os.system('dist%s%s%s.exe' % (test, os.sep, test))  
    85           os.environ["PATH"] = path  
      92  
      93         if run_executable:  
      94             _msg("EXECUTING TEST", src)  
      95             del os.environ["PATH"]  
      96             res = os.system('dist%s%s%s.exe' % (test, os.sep, test))  
      97             os.environ["PATH"] = path  
      98  
    86 99         if res == 0:  
      100             _msg("FINISHING TEST", src, short=1)  
    87 101             counter["passed"].append(src)  
    88               print "################## FINISHING TEST %s ################################" % src  
    89 102         else:  
      103             _msg("TEST", src, "FAILED", short=1)  
    90 104             counter["failed"].append(src)  
    91               print "#################### TEST %s FAILED #################################" % src  
    92 105     print counter  
    93 106  
      107  
    94 108 if __name__ == '__main__':  
    95 109     normal_tests = glob.glob('test*[0-9].py')  
     
    98 112     args = sys.argv[1:]  
    99 113  
      114     run_executable = 1  
      115     if "-n" in args:  
      116         # Do not run the built executables. Useful for cross builds.  
      117         run_executable = 0  
    100 118     if "-c" in args:  
    101 119         # only clean up  
     
    110 128     clean()  
    111 129     if tests:  
    112           runtests(tests)  
      130         runtests(tests, run_executable=run_executable)