Changeset 74

Show
Ignore:
Timestamp:
12/29/05 14:56:16 (3 years ago)
Author:
tim
Message:

extended tests and added a build.py file in advance of extracting a runner script. Also imrproved recursive remove directory in utils.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/timcommithook/pyramid/build.py

    r69 r74  
    5151    # dangerous remove directory contents function 
    5252    if not partialbuild: 
    53         utils.recursiveRemoveDirectory(OUTPUTDIR) 
     53        utils.recursiveRemoveDirectoryContents(OUTPUTDIR) 
    5454     
    5555    # copy in any resources needed 
  • branches/timcommithook/pyramid/test/tests.py

    r68 r74  
    11import unittest 
    2 from pyramid import flatteners, yamlRegistry as Y, build 
     2from pyramid import flatteners, yamlRegistry as Y, build, utils, path 
    33import os.path 
     4import sys 
     5import difflib 
     6import wingdbstub 
    47 
    5 testdatadir = 'testdata' 
    6 TEMPFOLDER = '/tmp/pyramidtest' 
     8testdatadir = path.path('testdata') 
     9TEMPFOLDER = path.path('/tmp/pyramidtest') 
    710 
    811def removeTemp(dir): 
    9     if os.path.isdir(dir): 
     12    if os.path.isdir(dir) and dir.startswith(TEMPFOLDER): 
     13        utils.recursiveRemoveDirectoryContents(dir) 
    1014        os.rmdir(dir) 
     15    else: 
     16        print 'cant remove %s' % dir 
     17        sys.exit() 
    1118 
    1219def makeAndCleanTemp(dir): 
    13     removeTemp(dir) 
     20    if os.path.exists(dir): 
     21        removeTemp(dir) 
    1422    os.mkdir(dir)      
    1523 
     
    5361     
    5462    buildtestroot = 'build_tests' 
    55     testfolders = ['basic']     
     63    buildtestpath = path.path(os.getcwd()) / 'pyramid' / 'test' / testdatadir / buildtestroot 
    5664     
    5765    def setUp(self): 
     
    6472        """ 
    6573        """ 
    66         for folder in self.testfolders: 
    67             fullpath = os.path.join(os.getcwd(),'pyramid','test',testdatadir,self.buildtestroot,folder) 
    68             fullpathCorrectResuts = os.path.join(os.getcwd(),'pyramid','test',testdatadir,self.buildtestroot,'%s-checked'%folder) 
    69             build.build(fullpath,TEMPFOLDER) 
     74        skipdirs = ['.svn'] 
     75        tests = [d for d in os.listdir(self.buildtestpath) if d != '.svn'] 
     76         
     77        for buildtest in tests: 
     78             
     79            datapath = self.buildtestpath / buildtest / 'data' 
     80            checkedresultpath = self.buildtestpath / buildtest / 'expected' 
     81            checkedresultwithcachepath = self.buildtestpath / buildtest / 'withcache' 
     82            build.build(datapath,TEMPFOLDER / buildtest) 
     83             
     84            def compareDirs(actual,expected,skipdirs=[],skipfiles=[]): 
     85                for root, dirs, files in os.walk(checkedresultpath): 
     86                    relpath = checkedresultpath.relpathto(root) 
     87                    for dir in dirs: 
     88                        if dir in skipdirs: 
     89                            dirs.remove(dir) 
     90                    for file in files: 
     91                        if file not in skipfiles: 
     92                             
     93                            filetext1 = open(TEMPFOLDER / buildtest / relpath / file).readlines() 
     94                            filetext2 = open(checkedresultpath / relpath / file).readlines() 
     95                            d = difflib.Differ() 
     96                            result = list(difflib.context_diff(filetext1,filetext2)) 
     97                            if len(result) > 0: 
     98                                print '\n'.join(result) 
     99                                return False 
     100                return True 
     101             
     102            self.assertEqual(compareDirs(TEMPFOLDER / buildtest,checkedresultpath,skipdirs,['.cache.dump']),True) 
     103            self.assertEqual(compareDirs(TEMPFOLDER / buildtest,checkedresultwithcachepath,skipdirs),True) 
     104             
     105                         
     106                  
    70107             
    71108         
  • branches/timcommithook/pyramid/utils.py

    r1 r74  
    5656    return lstripline, len(line)-len(lstripline) 
    5757     
    58 def recursiveRemoveDirectory(dir): 
     58def recursiveRemoveDirectoryContents(dir): 
    5959    for root, dirs, files in os.walk(dir, topdown=False): 
    6060        for name in files: