5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 test
= TestSCons
.TestSCons()
35 foo1
= test
.workpath('foo1' + _exe
)
36 foo2
= test
.workpath('foo2' + _exe
)
37 foo3
= test
.workpath('foo3' + _exe
)
38 foo4
= test
.workpath('foo4' + _exe
)
39 foo5
= test
.workpath('foo5' + _exe
)
40 foo_args
= 'foo1%s foo2%s foo3%s foo4%s foo5%s' % (_exe
, _exe
, _exe
, _exe
, _exe
)
42 test
.write('SConstruct', """\
43 DefaultEnvironment(tools=[]) # test speedup
45 env.Program(target='foo1', source='f1.c')
46 env.Program(target='foo2', source=Split('f2a.c f2b.c f2c.c'))
49 env.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")
166 test
.up_to_date(arguments
='.')
168 test
.write('f1.c', r
"""
172 main(int argc, char *argv[])
180 test
.write('f3b.c', r
"""
189 test
.write('f4.c', r
"""
193 main(int argc, char *argv[])
201 test
.write('foo5.c', r
"""
205 main(int argc, char *argv[])
208 printf("foo5.c X\n");
213 test
.run(arguments
='.')
215 test
.run(program
=foo1
, stdout
="f1.c X\n")
216 test
.run(program
=foo2
, stdout
="f2a.c\nf2b.c\nf2c.c\n")
217 test
.run(program
=foo3
, stdout
="f3a.c\nf3b.c X\nf3c.c\n")
218 test
.run(program
=foo4
, stdout
="f4.c X\n")
219 test
.run(program
=foo5
, stdout
="foo5.c X\n")
220 test
.up_to_date(arguments
='.')
222 # make sure the programs didn't get rebuilt, because nothing changed:
223 oldtime1
= os
.path
.getmtime(foo1
)
224 oldtime2
= os
.path
.getmtime(foo2
)
225 oldtime3
= os
.path
.getmtime(foo3
)
226 oldtime4
= os
.path
.getmtime(foo4
)
227 oldtime5
= os
.path
.getmtime(foo5
)
229 test
.sleep() # delay for timestamps
230 test
.run(arguments
=foo_args
)
231 test
.fail_test(oldtime1
!= os
.path
.getmtime(foo1
))
232 test
.fail_test(oldtime2
!= os
.path
.getmtime(foo2
))
233 test
.fail_test(oldtime3
!= os
.path
.getmtime(foo3
))
234 test
.fail_test(oldtime4
!= os
.path
.getmtime(foo4
))
235 test
.fail_test(oldtime5
!= os
.path
.getmtime(foo5
))
237 test
.write('f1.c', r
"""
241 main(int argc, char *argv[])
249 test
.write('f3b.c', r
"""
259 test
.write('f4.c', r
"""
263 main(int argc, char *argv[])
271 test
.write('foo5.c', r
"""
275 main(int argc, char *argv[])
278 printf("foo5.c Y\n");
283 test
.run(arguments
=foo_args
)
285 test
.run(program
=foo1
, stdout
="f1.c Y\n")
286 test
.run(program
=foo2
, stdout
="f2a.c\nf2b.c\nf2c.c\n")
287 test
.run(program
=foo3
, stdout
="f3a.c\nf3b.c Y\nf3c.c\n")
288 test
.run(program
=foo4
, stdout
="f4.c Y\n")
289 test
.run(program
=foo5
, stdout
="foo5.c Y\n")
290 test
.up_to_date(arguments
=foo_args
)
292 test
.write('f1.c', r
"""
296 main(int argc, char *argv[])
304 test
.write('f3b.c', r
"""
314 test
.write('f4.c', r
"""
318 main(int argc, char *argv[])
326 test
.write('foo5.c', r
"""
330 main(int argc, char *argv[])
333 printf("foo5.c Z\n");
338 test
.run(arguments
=foo_args
)
340 test
.run(program
=foo1
, stdout
="f1.c Z\n")
341 test
.run(program
=foo2
, stdout
="f2a.c\nf2b.c\nf2c.c\n")
342 test
.run(program
=foo3
, stdout
="f3a.c\nf3b.c Z\nf3c.c\n")
343 test
.run(program
=foo4
, stdout
="f4.c Z\n")
344 test
.run(program
=foo5
, stdout
="foo5.c Z\n")
345 test
.up_to_date(arguments
=foo_args
)
347 # make sure the programs didn't get rebuilt, because nothing changed:
348 oldtime1
= os
.path
.getmtime(foo1
)
349 oldtime2
= os
.path
.getmtime(foo2
)
350 oldtime3
= os
.path
.getmtime(foo3
)
351 oldtime4
= os
.path
.getmtime(foo4
)
352 oldtime5
= os
.path
.getmtime(foo5
)
354 test
.sleep() # delay for timestamps
355 test
.run(arguments
=foo_args
)
356 test
.fail_test(not (oldtime1
== os
.path
.getmtime(foo1
)))
357 test
.fail_test(not (oldtime2
== os
.path
.getmtime(foo2
)))
358 test
.fail_test(not (oldtime3
== os
.path
.getmtime(foo3
)))
359 test
.fail_test(not (oldtime4
== os
.path
.getmtime(foo4
)))
360 test
.fail_test(not (oldtime5
== os
.path
.getmtime(foo5
)))
366 # indent-tabs-mode:nil
368 # vim: set expandtab tabstop=4 shiftwidth=4: