~ubuntu-branches/ubuntu/maverick/pygame/maverick

« back to all changes in this revision

Viewing changes to configtest/test_config_win.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-01-14 17:02:11 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100114170211-21eop2ja7mr9vdcr
Tags: 1.9.1release-0ubuntu1
* New upstream version (lp: #433304)
* debian/control:
  - build-depends on libportmidi-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# program test_config_msys.py
2
 
 
3
 
"""Test config_msys.py for against a dummy directory structure.
4
 
 
5
 
This test must be performed on an MSYS console.
6
 
"""
7
 
 
8
 
import sys
9
 
sys.path.append('..')
10
 
import config_win
11
 
import dll
12
 
 
13
 
import unittest
14
 
import os
15
 
 
16
 
test_dir = 'testdir'
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'))
20
 
 
21
 
dependencies = dict([(dep.name, dep) for dep in config_win.main()])
22
 
 
23
 
 
24
 
class RunConfigTestCase(unittest.TestCase):
25
 
    """Test dependencies returned by config_win.main()"""
26
 
 
27
 
    class Dependency(object):
28
 
        # Holds dependency info
29
 
        def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None):
30
 
            if libs is None:
31
 
                if name is None:
32
 
                    libs = []
33
 
                else:
34
 
                    libs = [dll.name_to_root(name)]
35
 
            self.libs = libs
36
 
            self.inc_dir = None
37
 
            self.lib_dir = None
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)
42
 
 
43
 
    # Pygame dependencies
44
 
    expectations = {
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'),
71
 
        }
72
 
 
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)
78
 
 
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)
83
 
 
84
 
    def test_found(self):
85
 
        """Ensure all dependencies were found"""
86
 
        for dep in dependencies.values():
87
 
            self.failUnless(dep.found, dep.name)
88
 
 
89
 
    # def test_not_found(self):
90
 
    # No easy way to test the case where something is missing
91
 
 
92
 
    def test_libs(self):
93
 
        """Ensure each dependency has the proper libraries"""
94
 
        for name, dep in dependencies.items():
95
 
            dlibs = dep.libs
96
 
            elibs = self.expectations[name].libs
97
 
            self.failUnlessEqual(dlibs, elibs, "%s: %s != %s" % (name, dlibs, elibs))
98
 
 
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))
107
 
 
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))
116
 
 
117
 
if __name__ == '__main__':
118
 
    unittest.main()