1
# program test_config_msys.py
3
"""Test config_msys.py for against a dummy directory structure.
5
This test must be performed on an MSYS console.
17
if not os.path.isdir(test_dir):
18
print "Test directory %s not found." % test_dir
19
os.chdir(os.path.join(test_dir, 'include'))
21
dependencies = dict([(dep.name, dep) for dep in config_win.main()])
24
class RunConfigTestCase(unittest.TestCase):
25
"""Test dependencies returned by config_win.main()"""
27
class Dependency(object):
28
# Holds dependency info
29
def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None):
34
libs = [dll.name_to_root(name)]
38
if inc_dir_rel is not None:
39
self.inc_dir = '%s/%s' % ('..', inc_dir_rel)
40
if lib_dir_rel is not None:
41
self.lib_dir = '%s/%s' % ('..', lib_dir_rel)
45
'SDL': Dependency('SDL', 'sdl-1.2.12/include', 'sdl-1.2.12/visualc/sdl/release'),
46
'FONT': Dependency('FONT', 'sdl_ttf-2.0.9', 'sdl_ttf-2.0.9/release'),
47
'IMAGE': Dependency('IMAGE', 'sdl_image-1.2.6', 'sdl_image-1.2.6/visualc/release'),
48
'MIXER': Dependency('MIXER', 'sdl_mixer-1.2.8', 'sdl_mixer-1.2.8/release'),
49
'SMPEG': Dependency('SMPEG', 'smpeg', 'smpeg/release'),
50
'PNG': Dependency('PNG', 'libpng-1.2.19', 'libpng-1.2.19/lib'),
51
'JPEG': Dependency('JPEG', 'jpeg-6b', 'jpeg-6b/release'),
52
'SCRAP': Dependency(libs=['user32', 'gdi32']),
53
'COPYLIB_SDL': Dependency('SDL',
54
lib_dir_rel='sdl-1.2.12/visualc/sdl/release/sdl.dll'),
55
'COPYLIB_FONT': Dependency('FONT',
56
lib_dir_rel='sdl_ttf-2.0.9/release/sdl_ttf.dll'),
57
'COPYLIB_IMAGE': Dependency('IMAGE',
58
lib_dir_rel='sdl_image-1.2.6/visualc/release/sdl_image.dll'),
59
'COPYLIB_MIXER': Dependency('MIXER',
60
lib_dir_rel='sdl_mixer-1.2.8/release/sdl_mixer.dll'),
61
'COPYLIB_SMPEG': Dependency('SMPEG', lib_dir_rel='smpeg/release/smpeg.dll'),
62
'COPYLIB_TIFF': Dependency('TIFF', lib_dir_rel='tiff-3.8.2/release/libtiff.dll'),
63
'COPYLIB_PNG': Dependency('PNG', lib_dir_rel='libpng-1.2.19/lib/libpng13.dll'),
64
'COPYLIB_JPEG': Dependency('JPEG', lib_dir_rel='jpeg-6b/release/jpeg.dll'),
65
'COPYLIB_Z': Dependency('Z', lib_dir_rel='zlib-1.2.3/release/zlib1.dll'),
66
'COPYLIB_VORBISFILE': Dependency('VORBISFILE',
67
lib_dir_rel='libvorbis-1.2.0/release/libvorbisfile-3.dll'),
68
'COPYLIB_VORBIS': Dependency('VORBIS',
69
lib_dir_rel='libvorbis-1.2.0/release/libvorbis-0.dll'),
70
'COPYLIB_OGG': Dependency('OGG', lib_dir_rel='libogg-1.1.3/release/libogg-0.dll'),
73
def test_dependencies(self):
74
"""Ensure all dependencies are present"""
75
self.failUnlessEqual(len(dependencies), len(self.expectations))
76
for name in self.expectations:
77
self.failUnless(name in dependencies, name)
79
def test_dll_match(self):
80
"""Ensure DLLs match with dll.py."""
81
for name in dll.regexs:
82
self.failUnless('COPYLIB_' + name in dependencies, name)
85
"""Ensure all dependencies were found"""
86
for dep in dependencies.values():
87
self.failUnless(dep.found, dep.name)
89
# def test_not_found(self):
90
# No easy way to test the case where something is missing
93
"""Ensure each dependency has the proper libraries"""
94
for name, dep in dependencies.items():
96
elibs = self.expectations[name].libs
97
self.failUnlessEqual(dlibs, elibs, "%s: %s != %s" % (name, dlibs, elibs))
99
def test_proper_include_paths(self):
100
"""Ensure each dependency has found its include directory"""
101
for name, dep in dependencies.items():
102
dinc_dir = dep.inc_dir
103
if dinc_dir is not None:
104
dinc_dir = dinc_dir.lower()
105
einc_dir = self.expectations[name].inc_dir
106
self.failUnlessEqual(dinc_dir, einc_dir, "%s: %s != %s" % (name, dinc_dir, einc_dir))
108
def test_proper_library_path(self):
109
"""Ensure each dependency has found its library directory/DLL file"""
110
for name, dep in dependencies.items():
111
dlib_dir = dep.lib_dir
112
if dlib_dir is not None:
113
dlib_dir = dlib_dir.lower()
114
elib_dir = self.expectations[name].lib_dir
115
self.failUnlessEqual(dlib_dir, elib_dir, "%s: %s != %s" % (name, dlib_dir, elib_dir))
117
if __name__ == '__main__':