4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 import SCons.Scanner.RC
36 test = TestCmd.TestCmd(workdir = '')
38 os.chdir(test.workpath(''))
40 # create some source files and headers:
42 test.write('t1.rc','''
46 test.write('t2.rc',"""
48 ICO_TEST ICON DISCARDABLE "abc.ico"
49 BMP_TEST BITMAP DISCARDABLE "def.bmp"
50 cursor1 CURSOR "bullseye.cur"
51 ID_RESPONSE_ERROR_PAGE HTML "responseerrorpage.htm"
53 1 MESSAGETABLE "MSG00409.bin"
54 1 MESSAGETABLE MSG00410.bin
55 1 TYPELIB "testtypelib.tlb"
56 TEST_REGIS REGISTRY MOVEABLE PURE "testregis.rgs"
57 TEST_D3DFX D3DFX DISCARDABLE "testEffect.fx"
62 # Create dummy include files
64 'abc.ico','def.bmp','bullseye.cur','responseerrorpage.htm','cmroman.fnt',
66 'MSG00409.bin','MSG00410.bin','testtypelib.tlb','testregis.rgs']
72 # define some helpers:
74 class DummyEnvironment(UserDict.UserDict):
75 def __init__(self,**kw):
76 UserDict.UserDict.__init__(self)
78 self.fs = SCons.Node.FS.FS(test.workpath(''))
80 def Dictionary(self, *args):
83 def subst(self, arg, target=None, source=None, conv=None):
84 if strSubst[0] == '$':
85 return self.data[strSubst[1:]]
88 def subst_path(self, path, target=None, source=None, conv=None):
89 if not isinstance(path, list):
91 return list(map(self.subst, path))
93 def has_key(self, key):
94 return key in self.Dictionary()
96 def get_calculator(self):
99 def get_factory(self, factory):
100 return factory or self.fs.File
102 def Dir(self, filename):
103 return self.fs.Dir(filename)
105 def File(self, filename):
106 return self.fs.File(filename)
109 my_normpath = os.path.normpath
111 if os.path.normcase('foo') == os.path.normcase('FOO'):
112 my_normpath = os.path.normcase
114 def deps_match(self, deps, headers):
115 scanned = sorted(map(my_normpath, list(map(str, deps))))
116 expect = sorted(map(my_normpath, headers))
117 self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
121 class RCScannerTestCase1(unittest.TestCase):
124 env = DummyEnvironment(RCSUFFIXES=['.rc','.rc2'],
126 s = SCons.Scanner.RC.RCScan()
127 deps = s(env.File('t1.rc'), env, path)
129 deps_match(self, deps, headers)
131 class RCScannerTestCase2(unittest.TestCase):
134 env = DummyEnvironment(RCSUFFIXES=['.rc','.rc2'],
136 s = SCons.Scanner.RC.RCScan()
137 deps = s(env.File('t2.rc'), env, path)
138 headers = ['MSG00410.bin',
139 'abc.ico','bullseye.cur',
140 'cmroman.fnt','def.bmp',
142 'responseerrorpage.htm',
145 'testregis.rgs','testtypelib.tlb']
146 deps_match(self, deps, headers)
151 suite = unittest.TestSuite()
152 suite.addTest(RCScannerTestCase1())
153 suite.addTest(RCScannerTestCase2())
156 if __name__ == "__main__":
157 runner = unittest.TextTestRunner()
158 result = runner.run(suite())
159 if not result.wasSuccessful():
164 # indent-tabs-mode:nil
166 # vim: set expandtab tabstop=4 shiftwidth=4: