added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / AlwaysBuild.py
blob55e6f27bf223bf4de76e9772e57bc424bdbaf04e
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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.
26 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 import os
30 import TestSCons
32 test = TestSCons.TestSCons()
34 test.subdir('sub')
36 sub_f3_out = os.path.join('sub', 'f3.out')
37 _SUBDIR_f3_out = os.path.join('$SUBDIR', 'f3.out')
39 test.write('SConstruct', """\
40 def bfunc(target, source, env):
41 import shutil
42 shutil.copyfile('f2.in', str(target[0]))
44 B = Builder(action=bfunc)
45 env = Environment(BUILDERS = { 'B' : B }, SUBDIR='sub')
46 env.B('f1.out', source='f1.in')
47 AlwaysBuild('f1.out')
49 env.B(r'%(sub_f3_out)s', source='f3.in')
50 env.AlwaysBuild(r'%(_SUBDIR_f3_out)s')
52 env.Alias('clean1', [], Delete('clean1-target'))
53 env.AlwaysBuild('clean1')
54 c2 = env.Alias('clean2', [], [Delete('clean2-t1'), Delete('clean2-t2')])
55 env.AlwaysBuild(c2)
57 def dir_build(target, source, env):
58 with open('dir_build.txt', 'ab') as f:
59 f.write(b'dir_build()\\n')
60 env.Command(Dir('dir'), None, dir_build)
61 env.AlwaysBuild('dir')
62 """ % locals())
64 test.write('f1.in', "f1.in\n")
65 test.write('f2.in', "1")
66 test.write('f3.in', "f3.in\n")
68 test.subdir('dir')
70 test.run(arguments = ".")
71 test.must_match('f1.out', '1')
72 test.must_match(['sub', 'f3.out'], '1')
73 test.must_match('dir_build.txt', "dir_build()\n")
75 test.write('f2.in', "2")
77 test.run(arguments = ".")
78 test.must_match('f1.out', '2')
79 test.must_match(['sub', 'f3.out'], '2')
80 test.must_match('dir_build.txt', "dir_build()\ndir_build()\n")
82 test.run(arguments = 'clean1', stdout=test.wrap_stdout("""\
83 Delete("clean1-target")
84 """))
86 test.run(arguments = 'clean2', stdout=test.wrap_stdout("""\
87 Delete("clean2-t1")
88 Delete("clean2-t2")
89 """))
91 test.not_up_to_date(arguments = 'dir')
93 test.must_match('dir_build.txt', "dir_build()\ndir_build()\ndir_build()\n")
95 test.pass_test()
97 # Local Variables:
98 # tab-width:4
99 # indent-tabs-mode:nil
100 # End:
101 # vim: set expandtab tabstop=4 shiftwidth=4: