5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
34 test = TestSCons.TestSCons()
36 foo1 = test.workpath('foo1' + _exe)
37 foo2 = test.workpath('foo2' + _exe)
38 foo3 = test.workpath('foo3' + _exe)
39 foo4 = test.workpath('foo4' + _exe)
40 foo5 = test.workpath('foo5' + _exe)
41 foo_args = 'foo1%s foo2%s foo3%s foo4%s foo5%s' % (_exe, _exe, _exe, _exe, _exe)
43 test.write('SConstruct', """
45 env.Program(target = 'foo1', source = 'f1.c')
46 env.Program(target = 'foo2', source = Split('f2a.c f2b.c f2c.c'))
49 Program(target = 'foo3', source = [f3a, [f3b, 'f3c.c']])
50 env.Program('foo4', 'f4.c')
54 test.write('f1.c', r"""
56 main(int argc, char *argv[])
64 test.write('f2a.c', r"""
72 test.write('f2b.c', r"""
80 test.write('f2c.c', r"""
81 extern void f2a(void);
82 extern void f2b(void);
84 main(int argc, char *argv[])
94 test.write('f3a.c', r"""
102 test.write('f3b.c', r"""
110 test.write('f3c.c', r"""
111 extern void f3a(void);
112 extern void f3b(void);
114 main(int argc, char *argv[])
124 test.write('f4.c', r"""
126 main(int argc, char *argv[])
134 test.write('foo5.c', r"""
136 main(int argc, char *argv[])
144 test.run(arguments = '.')
146 test.run(program = foo1, stdout = "f1.c\n")
147 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
148 test.run(program = foo3, stdout = "f3a.c\nf3b.c\nf3c.c\n")
149 test.run(program = foo4, stdout = "f4.c\n")
150 test.run(program = foo5, stdout = "foo5.c\n")
152 test.up_to_date(arguments = '.')
154 test.write('f1.c', r"""
156 main(int argc, char *argv[])
164 test.write('f3b.c', r"""
172 test.write('f4.c', r"""
174 main(int argc, char *argv[])
182 test.write('foo5.c', r"""
184 main(int argc, char *argv[])
187 printf("foo5.c X\n");
192 test.run(arguments = '.')
194 test.run(program = foo1, stdout = "f1.c X\n")
195 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
196 test.run(program = foo3, stdout = "f3a.c\nf3b.c X\nf3c.c\n")
197 test.run(program = foo4, stdout = "f4.c X\n")
198 test.run(program = foo5, stdout = "foo5.c X\n")
200 test.up_to_date(arguments = '.')
202 # make sure the programs didn't get rebuilt, because nothing changed:
203 oldtime1 = os.path.getmtime(foo1)
204 oldtime2 = os.path.getmtime(foo2)
205 oldtime3 = os.path.getmtime(foo3)
206 oldtime4 = os.path.getmtime(foo4)
207 oldtime5 = os.path.getmtime(foo5)
209 time.sleep(2) # introduce a small delay, to make the test valid
211 test.run(arguments = foo_args)
213 test.fail_test(oldtime1 != os.path.getmtime(foo1))
214 test.fail_test(oldtime2 != os.path.getmtime(foo2))
215 test.fail_test(oldtime3 != os.path.getmtime(foo3))
216 test.fail_test(oldtime4 != os.path.getmtime(foo4))
217 test.fail_test(oldtime5 != os.path.getmtime(foo5))
219 test.write('f1.c', r"""
221 main(int argc, char *argv[])
229 test.write('f3b.c', r"""
237 test.write('f4.c', r"""
239 main(int argc, char *argv[])
247 test.write('foo5.c', r"""
249 main(int argc, char *argv[])
252 printf("foo5.c Y\n");
257 test.run(arguments = foo_args)
259 test.run(program = foo1, stdout = "f1.c Y\n")
260 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
261 test.run(program = foo3, stdout = "f3a.c\nf3b.c Y\nf3c.c\n")
262 test.run(program = foo4, stdout = "f4.c Y\n")
263 test.run(program = foo5, stdout = "foo5.c Y\n")
265 test.up_to_date(arguments = foo_args)
267 test.write('f1.c', r"""
269 main(int argc, char *argv[])
277 test.write('f3b.c', r"""
285 test.write('f4.c', r"""
287 main(int argc, char *argv[])
295 test.write('foo5.c', r"""
297 main(int argc, char *argv[])
300 printf("foo5.c Z\n");
305 test.run(arguments = foo_args)
307 test.run(program = foo1, stdout = "f1.c Z\n")
308 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
309 test.run(program = foo3, stdout = "f3a.c\nf3b.c Z\nf3c.c\n")
310 test.run(program = foo4, stdout = "f4.c Z\n")
311 test.run(program = foo5, stdout = "foo5.c Z\n")
313 test.up_to_date(arguments = foo_args)
315 # make sure the programs didn't get rebuilt, because nothing changed:
316 oldtime1 = os.path.getmtime(foo1)
317 oldtime2 = os.path.getmtime(foo2)
318 oldtime3 = os.path.getmtime(foo3)
319 oldtime4 = os.path.getmtime(foo4)
320 oldtime5 = os.path.getmtime(foo5)
322 time.sleep(2) # introduce a small delay, to make the test valid
324 test.run(arguments = foo_args)
326 test.fail_test(not (oldtime1 == os.path.getmtime(foo1)))
327 test.fail_test(not (oldtime2 == os.path.getmtime(foo2)))
328 test.fail_test(not (oldtime3 == os.path.getmtime(foo3)))
329 test.fail_test(not (oldtime4 == os.path.getmtime(foo4)))
330 test.fail_test(not (oldtime5 == os.path.getmtime(foo5)))