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.
31 _python_
= TestSCons
._python
_
33 test
= TestSCons
.TestSCons(match
=TestCmd
.match_re
)
35 test
.subdir('sub1', 'sub2')
37 test
.write('build.py', r
"""
39 with open(sys.argv[1], 'wb') as f, open(sys.argv[2], 'rb') as ifp:
44 test
.write('SConstruct', """
45 B = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
46 DefaultEnvironment(tools=[]) # test speedup
47 env = Environment(tools=[])
48 env['BUILDERS']['B'] = B
49 env.B(target = 'f1.out', source = 'f1.in')
50 env.B(target = 'f2.out', source = 'f2.in')
51 env.B(target = 'f3.out', source = 'f3.in')
52 SConscript('sub1/SConscript', "env")
53 SConscript('sub2/SConscript', "env")
56 foo2 = env.Alias('foo', ['f2.out', 'sub1'])
58 bar = Alias('bar', ['sub2', 'f3.out'])
59 env.Alias('blat', ['sub2', 'f3.out'])
60 env.Alias('blat', ['f2.out', 'sub1'])
61 env.Depends('f1.out', 'bar')
63 assert Alias('foo') == foo
64 assert Alias('bar') == bar
68 test
.write(['sub1', 'SConscript'], """
70 env.B(target = 'f4.out', source = 'f4.in')
71 env.B(target = 'f5.out', source = 'f5.in')
72 env.B(target = 'f6.out', source = 'f6.in')
75 test
.write(['sub2', 'SConscript'], """
77 env.B(target = 'f7.out', source = 'f7.in')
78 env.B(target = 'f8.out', source = 'f8.in')
79 env.B(target = 'f9.out', source = 'f9.in')
82 test
.write('f1.in', "f1.in\n")
83 test
.write('f2.in', "f2.in\n")
84 test
.write('f3.in', "f3.in\n")
86 test
.write(['sub1', 'f4.in'], "sub1/f4.in\n")
87 test
.write(['sub1', 'f5.in'], "sub1/f5.in\n")
88 test
.write(['sub1', 'f6.in'], "sub1/f6.in\n")
90 test
.write(['sub2', 'f7.in'], "sub2/f7.in\n")
91 test
.write(['sub2', 'f8.in'], "sub2/f8.in\n")
92 test
.write(['sub2', 'f9.in'], "sub2/f9.in\n")
94 test
.run(arguments
= 'foo')
96 test
.fail_test(os
.path
.exists(test
.workpath('f1.out')))
97 test
.fail_test(not os
.path
.exists(test
.workpath('f2.out')))
98 test
.fail_test(os
.path
.exists(test
.workpath('f3.out')))
100 test
.fail_test(not os
.path
.exists(test
.workpath('sub1', 'f4.out')))
101 test
.fail_test(not os
.path
.exists(test
.workpath('sub1', 'f5.out')))
102 test
.fail_test(not os
.path
.exists(test
.workpath('sub1', 'f6.out')))
104 test
.fail_test(os
.path
.exists(test
.workpath('sub2', 'f7.out')))
105 test
.fail_test(os
.path
.exists(test
.workpath('sub2', 'f8.out')))
106 test
.fail_test(os
.path
.exists(test
.workpath('sub2', 'f9.out')))
108 test
.up_to_date(arguments
= 'foo')
110 test
.run(arguments
= 'f1.out')
112 test
.fail_test(not os
.path
.exists(test
.workpath('f1.out')))
113 test
.fail_test(not os
.path
.exists(test
.workpath('f3.out')))
115 test
.fail_test(not os
.path
.exists(test
.workpath('sub2', 'f7.out')))
116 test
.fail_test(not os
.path
.exists(test
.workpath('sub2', 'f8.out')))
117 test
.fail_test(not os
.path
.exists(test
.workpath('sub2', 'f9.out')))
119 test
.up_to_date(arguments
= 'f1.out')
121 os
.unlink(test
.workpath('f2.out'))
122 os
.unlink(test
.workpath('f3.out'))
124 test
.run(arguments
= 'blat')
126 test
.fail_test(not os
.path
.exists(test
.workpath('f2.out')))
127 test
.fail_test(not os
.path
.exists(test
.workpath('f3.out')))
129 test
.write('f3.in', "f3.in 2 \n")
131 test
.run(arguments
= 'f1.out',
132 stdout
= test
.wrap_stdout(".* build.py f3.out f3.in\n.* build.py f1.out f1.in\n"))
134 test
.up_to_date(arguments
= 'f1.out')
136 test
.write('SConstruct', """
138 B = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
139 DefaultEnvironment(tools=[]) # test speedup
140 env = Environment(tools=[])
141 env['BUILDERS']['B'] = B
142 env.B(target = 'f1.out', source = 'f1.in')
143 env.B(target = 'f2.out', source = 'f2.in')
144 env.B(target = 'f3.out', source = 'f3.in')
145 SConscript('sub1/SConscript', "env")
146 SConscript('sub2/SConscript', "env")
147 env.Alias('foo', ['f2.out', 'sub1'])
148 env.Alias('bar', ['sub2', 'f3.out'])
149 env.Alias('blat', ['sub2', 'f3.out'])
150 env.Alias('blat', ['f2.out', 'sub1'])
151 env.Depends('f1.out', 'bar')
154 os
.unlink(test
.workpath('f1.out'))
156 test
.run(arguments
= 'f1.out')
158 test
.fail_test(not os
.path
.exists(test
.workpath('f1.out')))
160 test
.write('f3.in', "f3.in 3 \n")
162 expect
= test
.wrap_stdout("""\
163 %(_python_)s build.py f3.out f3.in
164 %(_python_)s build.py f1.out f1.in
167 test
.run(arguments
= 'f1.out', match
= TestCmd
.match_exact
, stdout
= expect
)
169 test
.up_to_date(arguments
= 'f1.out')
175 # indent-tabs-mode:nil
177 # vim: set expandtab tabstop=4 shiftwidth=4: