# program test_config_msys.py"""Test config_msys.py for against a dummy directory structure.This test must be performed on an MSYS console."""importsyssys.path.append('..')importconfig_winimportunittestimportostest_dir='testdir'ifnotos.path.isdir(test_dir):print"Test directory %s not found."%test_diros.chdir(os.path.join(test_dir,'include'))dependencies=dict([(dep.name,dep)fordepinconfig_win.main()])classRunConfigTestCase(unittest.TestCase):"""Test dependencies returned by config_win.main()"""classDependency(object):# Holds dependency infodef__init__(self,lib=None,inc_dir_rel=None,lib_dir_rel=None,libs=None,cflags=None):iflibsisNone:iflibsisnotNone:libs=libseliflibisnotNone:libs=[lib]else:libs=[]ifcflagsisNone:cflags=''self.libs=libsself.inc_dir=Noneself.lib_dir=Noneifinc_dir_relisnotNone:self.inc_dir='%s/%s'%('..',inc_dir_rel)iflib_dir_relisnotNone:self.lib_dir='%s/%s'%('..',lib_dir_rel)self.cflags=cflags# Pygame dependenciesexpectations={'SDL':Dependency('SDL','sdl-1.2/include','sdl-1.2/visualc/sdl/release'),'FONT':Dependency('SDL_ttf','sdl_ttf-2.0.9','sdl_ttf-2.0.9/release'),'IMAGE':Dependency('SDL_image','sdl_image-1.2.6','sdl_image-1.2.6/visualc/release'),'MIXER':Dependency('SDL_mixer','sdl_mixer-1.2','sdl_mixer-1.2/release'),'SMPEG':Dependency('smpeg','smpeg','smpeg/release'),'PNG':Dependency('png','libpng-1.2.32','libpng-1.2.32/lib'),'JPEG':Dependency('jpeg','jpeg-6b','jpeg-6b/release'),'SCRAP':Dependency(cflags=' -luser32 -lgdi32'),'COPYLIB_SDL':Dependency(lib_dir_rel='sdl-1.2/visualc/sdl/release/sdl.dll'),'COPYLIB_SDL_ttf':Dependency(libs=['SDL','z'],lib_dir_rel='sdl_ttf-2.0.9/release/sdl_ttf.dll'),'COPYLIB_SDL_image':Dependency(libs=['SDL','png','jpeg','tiff'],lib_dir_rel='sdl_image-1.2.6/visualc/release/sdl_image.dll'),'COPYLIB_SDL_mixer':Dependency(libs=['SDL','vorbisfile','smpeg'],lib_dir_rel='sdl_mixer-1.2/release/sdl_mixer.dll'),'COPYLIB_smpeg':Dependency(libs=['SDL'],lib_dir_rel='smpeg/release/smpeg.dll'),'COPYLIB_tiff':Dependency(libs=['jpeg','z'],lib_dir_rel='tiff-3.8.2/release/libtiff.dll'),'COPYLIB_png':Dependency(libs=['z'],lib_dir_rel='libpng-1.2.32/lib/libpng13.dll'),'COPYLIB_jpeg':Dependency(lib_dir_rel='jpeg-6b/release/jpeg.dll'),'COPYLIB_z':Dependency(lib_dir_rel='zlib-1.2.3/release/zlib1.dll'),'COPYLIB_vorbisfile':Dependency(libs=['vorbis'],lib_dir_rel='libvorbis-1.2.0/release/libvorbisfile-3.dll'),'COPYLIB_vorbis':Dependency(libs=['ogg'],lib_dir_rel='libvorbis-1.2.0/release/libvorbis-0.dll'),'COPYLIB_ogg':Dependency(lib_dir_rel='libogg-1.1.3/release/libogg-0.dll'),}deftest_dependencies(self):"""Ensure all dependencies are present"""self.failUnlessEqual(len(dependencies),len(self.expectations))fornameinself.expectations:self.failUnless(nameindependencies,name)deftest_found(self):"""Ensure all dependencies were found"""fordepindependencies.values():self.failUnless(dep.found,dep.name)# def test_not_found(self):# No easy way to test the case where something is missingdeftest_libs(self):"""Ensure each dependency has the proper libraries"""forname,depindependencies.items():dlibs=set(dep.libs)elibs=set(self.expectations[name].libs)self.failUnlessEqual(dlibs,elibs,"%s: %s != %s"%(name,dlibs,elibs))deftest_proper_include_paths(self):"""Ensure each dependency has found its include directory"""forname,depindependencies.items():dinc_dir=dep.inc_dirifdinc_dirisnotNone:dinc_dir=dinc_dir.lower()einc_dir=self.expectations[name].inc_dirself.failUnlessEqual(dinc_dir,einc_dir,"%s: %s != %s"%(name,dinc_dir,einc_dir))deftest_proper_library_path(self):"""Ensure each dependency has found its library directory/DLL file"""forname,depindependencies.items():dlib_dir=dep.lib_dirifdlib_dirisnotNone:dlib_dir=dlib_dir.lower()elib_dir=self.expectations[name].lib_dirself.failUnlessEqual(dlib_dir,elib_dir,"%s: %s != %s"%(name,dlib_dir,elib_dir))deftest_cflags(self):"""Ensure the cflags are properly set"""forname,depindependencies.items():dcflags=dep.cflagsecflags=self.expectations[name].cflagsself.failUnlessEqual(dcflags,ecflags,"%s: %s != %s"%(name,dcflags,ecflags))if__name__=='__main__':unittest.main()