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"""
58 main(int argc, char *argv[])
66 test.write('f2a.c', r"""
76 test.write('f2b.c', r"""
85 test.write('f2c.c', r"""
88 extern void f2a(void);
89 extern void f2b(void);
91 main(int argc, char *argv[])
101 test.write('f3a.c', r"""
110 test.write('f3b.c', r"""
119 test.write('f3c.c', r"""
122 extern void f3a(void);
123 extern void f3b(void);
125 main(int argc, char *argv[])
135 test.write('f4.c', r"""
139 main(int argc, char *argv[])
147 test.write('foo5.c', r"""
151 main(int argc, char *argv[])
159 test.run(arguments = '.')
161 test.run(program = foo1, stdout = "f1.c\n")
162 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
163 test.run(program = foo3, stdout = "f3a.c\nf3b.c\nf3c.c\n")
164 test.run(program = foo4, stdout = "f4.c\n")
165 test.run(program = foo5, stdout = "foo5.c\n")
167 test.up_to_date(arguments = '.')
169 test.write('f1.c', r"""
173 main(int argc, char *argv[])
181 test.write('f3b.c', r"""
190 test.write('f4.c', r"""
194 main(int argc, char *argv[])
202 test.write('foo5.c', r"""
206 main(int argc, char *argv[])
209 printf("foo5.c X\n");
214 test.run(arguments = '.')
216 test.run(program = foo1, stdout = "f1.c X\n")
217 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
218 test.run(program = foo3, stdout = "f3a.c\nf3b.c X\nf3c.c\n")
219 test.run(program = foo4, stdout = "f4.c X\n")
220 test.run(program = foo5, stdout = "foo5.c X\n")
222 test.up_to_date(arguments = '.')
224 # make sure the programs didn't get rebuilt, because nothing changed:
225 oldtime1 = os.path.getmtime(foo1)
226 oldtime2 = os.path.getmtime(foo2)
227 oldtime3 = os.path.getmtime(foo3)
228 oldtime4 = os.path.getmtime(foo4)
229 oldtime5 = os.path.getmtime(foo5)
231 time.sleep(2) # introduce a small delay, to make the test valid
233 test.run(arguments = foo_args)
235 test.fail_test(oldtime1 != os.path.getmtime(foo1))
236 test.fail_test(oldtime2 != os.path.getmtime(foo2))
237 test.fail_test(oldtime3 != os.path.getmtime(foo3))
238 test.fail_test(oldtime4 != os.path.getmtime(foo4))
239 test.fail_test(oldtime5 != os.path.getmtime(foo5))
241 test.write('f1.c', r"""
245 main(int argc, char *argv[])
253 test.write('f3b.c', r"""
263 test.write('f4.c', r"""
267 main(int argc, char *argv[])
275 test.write('foo5.c', r"""
279 main(int argc, char *argv[])
282 printf("foo5.c Y\n");
287 test.run(arguments = foo_args)
289 test.run(program = foo1, stdout = "f1.c Y\n")
290 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
291 test.run(program = foo3, stdout = "f3a.c\nf3b.c Y\nf3c.c\n")
292 test.run(program = foo4, stdout = "f4.c Y\n")
293 test.run(program = foo5, stdout = "foo5.c Y\n")
295 test.up_to_date(arguments = foo_args)
297 test.write('f1.c', r"""
301 main(int argc, char *argv[])
309 test.write('f3b.c', r"""
319 test.write('f4.c', r"""
323 main(int argc, char *argv[])
331 test.write('foo5.c', r"""
335 main(int argc, char *argv[])
338 printf("foo5.c Z\n");
343 test.run(arguments = foo_args)
345 test.run(program = foo1, stdout = "f1.c Z\n")
346 test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n")
347 test.run(program = foo3, stdout = "f3a.c\nf3b.c Z\nf3c.c\n")
348 test.run(program = foo4, stdout = "f4.c Z\n")
349 test.run(program = foo5, stdout = "foo5.c Z\n")
351 test.up_to_date(arguments = foo_args)
353 # make sure the programs didn't get rebuilt, because nothing changed:
354 oldtime1 = os.path.getmtime(foo1)
355 oldtime2 = os.path.getmtime(foo2)
356 oldtime3 = os.path.getmtime(foo3)
357 oldtime4 = os.path.getmtime(foo4)
358 oldtime5 = os.path.getmtime(foo5)
360 time.sleep(2) # introduce a small delay, to make the test valid
362 test.run(arguments = foo_args)
364 test.fail_test(not (oldtime1 == os.path.getmtime(foo1)))
365 test.fail_test(not (oldtime2 == os.path.getmtime(foo2)))
366 test.fail_test(not (oldtime3 == os.path.getmtime(foo3)))
367 test.fail_test(not (oldtime4 == os.path.getmtime(foo4)))
368 test.fail_test(not (oldtime5 == os.path.getmtime(foo5)))
374 # indent-tabs-mode:nil
376 # vim: set expandtab tabstop=4 shiftwidth=4: