Changeset 400

Show
Ignore:
Timestamp:
Fri Dec 21 13:20:49 2007
Author:
naufraghi
Message:

Rework path handling + add test selector

Files:

Legend:

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

    r101 r400  
    28 28 except NameError:  
    29 29     here=os.path.dirname(sys.argv[0])  
      30 os.chdir(here)  
    30 31 PYTHON = sys.executable  
    31 32 if sys.platform[:3] == 'win':  
     
    34 35  
    35 36 def clean():  
    36       distdirs = glob.glob(os.path.join(here, 'disttest*'))  
      37     distdirs = glob.glob('disttest*')  
    36 37     for dir in distdirs:  
    37 38         try:  
     
    40 41         except OSError, e:  
    41 42             print e  
    42       builddirs = glob.glob(os.path.join(here, 'buildtest*'))  
      43     builddirs = glob.glob('buildtest*')  
    42 43     for dir in builddirs:  
    43 44         try:  
     
    46 47         except OSError, e:  
    47 48             print e  
    48       wfiles = glob.glob(os.path.join(here, 'warn*.txt'))  
      49     wfiles = glob.glob('warn*.txt')  
    48 49     for file in wfiles:  
    49 50         try:  
     
    53 54             print e  
    54 55  
    55   def runtests():  
    56       global here  
    57       sources = glob.glob(os.path.join(here, 'test*[0-9].py'))  
      56 def runtests(sources=None):  
      57     info = "Executing PyInstaller tests in: %s" % os.getcwd()  
      58     print "*"*len(info)  
      59     print info  
      60     print "*"*len(info)  
      61     alltests = glob.glob('test*[0-9].py')  
      62     if not sources:  
      63         tests = alltests  
      64     else:  
      65         tests = []  
      66         for part in sources:  
      67             tests += [t for t in alltests if part in t and t not in tests]  
      68     tests.sort(key=lambda x: (len(x), x)) # test1 < test10  
    58 69     path = os.environ["PATH"]  
    59       for src in sources:  
      70     for src in tests:  
    59 70         print  
    60           print "################## EXECUTING TEST %s ################################" % src  
      71         print "################## BUILDING TEST %s #################################" % src  
    60 71         print  
    61 72         test = os.path.splitext(os.path.basename(src))[0]  
     
    65 76         # Run the test in a clean environment to make sure they're really self-contained  
    66 77         del os.environ["PATH"]  
    67           os.system('dist%s%s%s' % (test, os.sep, test))  
      78         print  
      79         print "################## EXECUTING TEST %s ################################" % src  
      80         print  
      81         res = os.system('dist%s%s%s.exe' % (test, os.sep, test))  
    68 82         os.environ["PATH"] = path  
    69           print "################## FINISHING TEST %s  ################################" % src  
      83         assert res == 0, "%s Test error!" % src  
      84         print "################## FINISHING TEST %s ################################" % src  
    70 85  
    71 86 if __name__ == '__main__':  
     
    76 91         clean()  
    77 92     if '--run' in sys.argv:  
    78           runtests()  
    79       raw_input("Press any key to exit")  
      93         runtests(sys.argv[2:])