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__"
30 _python_
= TestSCons
._python
_
32 test
= TestSCons
.TestSCons()
34 test
.subdir('work1', 'work2', 'work3')
38 test
.write('succeed.py', r
"""
40 file = open(sys.argv[1], 'w')
41 file.write("succeed.py: %s\n" % sys.argv[1])
46 test
.write('fail.py', r
"""
56 test
.write(['work1', 'SConstruct'], """\
57 DefaultEnvironment(tools=[])
58 Succeed = Builder(action=r'%(_python_)s ../succeed.py $TARGETS')
59 Fail = Builder(action=r'%(_python_)s ../fail.py $TARGETS')
60 env = Environment(BUILDERS={'Succeed': Succeed, 'Fail': Fail}, tools=[])
61 env.Fail(target='aaa.1', source='aaa.in')
62 env.Succeed(target='aaa.out', source='aaa.1')
63 env.Succeed(target='bbb.out', source='bbb.in')
66 test
.write(['work1', 'aaa.in'], "aaa.in\n")
67 test
.write(['work1', 'bbb.in'], "bbb.in\n")
69 test
.run(chdir
='work1',
70 arguments
='aaa.out bbb.out',
71 stderr
='scons: *** [aaa.1] Error 1\n',
74 test
.must_not_exist(test
.workpath('work1', 'aaa.1'))
75 test
.must_not_exist(test
.workpath('work1', 'aaa.out'))
76 test
.must_not_exist(test
.workpath('work1', 'bbb.out'))
78 test
.run(chdir
='work1',
79 arguments
='-k aaa.out bbb.out',
80 stderr
='scons: *** [aaa.1] Error 1\n',
83 test
.must_not_exist(test
.workpath('work1', 'aaa.1'))
84 test
.must_not_exist(test
.workpath('work1', 'aaa.out'))
85 test
.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode
='r')
87 test
.unlink(['work1', 'bbb.out'])
89 test
.run(chdir
= 'work1',
90 arguments
='--keep-going aaa.out bbb.out',
91 stderr
='scons: *** [aaa.1] Error 1\n',
94 test
.must_not_exist(test
.workpath('work1', 'aaa.1'))
95 test
.must_not_exist(test
.workpath('work1', 'aaa.out'))
96 test
.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode
='r')
99 scons: Reading SConscript files ...
100 scons: done reading SConscript files.
101 scons: Cleaning targets ...
103 scons: done cleaning targets.
106 test
.run(chdir
='work1',
107 arguments
='--clean --keep-going aaa.out bbb.out',
110 test
.must_not_exist(test
.workpath('work1', 'aaa.1'))
111 test
.must_not_exist(test
.workpath('work1', 'aaa.out'))
112 test
.must_not_exist(test
.workpath('work1', 'bbb.out'))
120 test
.write(['work2', 'SConstruct'], """\
121 DefaultEnvironment(tools=[])
122 Succeed = Builder(action=r'%(_python_)s ../succeed.py $TARGETS')
123 Fail = Builder(action=r'%(_python_)s ../fail.py $TARGETS')
124 env = Environment(BUILDERS={'Succeed': Succeed, 'Fail': Fail}, tools=[])
125 env.Fail('aaa.out', 'aaa.in')
126 env.Succeed('bbb.out', 'aaa.out')
127 env.Succeed('ccc.out', 'ccc.in')
128 env.Succeed('ddd.out', 'ccc.in')
131 test
.write(['work2', 'aaa.in'], "aaa.in\n")
132 test
.write(['work2', 'ccc.in'], "ccc.in\n")
134 test
.run(chdir
='work2',
139 scons: Reading SConscript files ...
140 scons: done reading SConscript files.
141 scons: Building targets ...
142 %(_python_)s ../fail.py aaa.out
143 %(_python_)s ../succeed.py ccc.out
144 %(_python_)s ../succeed.py ddd.out
145 scons: done building targets (errors occurred during build).
148 test
.must_not_exist(['work2', 'aaa.out'])
149 test
.must_not_exist(['work2', 'bbb.out'])
150 test
.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n", mode
='r')
151 test
.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n", mode
='r')
158 # Check that the -k (keep-going) switch works correctly when the Nodes
159 # forms a DAG. The test case is the following
163 # +-----+-----+-------------+
167 # + +---+---+ +---+---+
169 # \ bbb.out / a4 ccc.out
176 test
.write(['work3', 'SConstruct'], """\
177 DefaultEnvironment(tools=[])
178 Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS')
179 Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS')
180 env = Environment(BUILDERS = {'Succeed': Succeed, 'Fail': Fail}, tools=[])
181 a = env.Fail('aaa.out', 'aaa.in')
182 b = env.Succeed('bbb.out', 'bbb.in')
183 c = env.Succeed('ccc.out', 'ccc.in')
185 a1 = Alias( 'a1', a )
186 a2 = Alias( 'a2', a+b)
188 a3 = Alias( 'a3', a4+c)
190 Alias('all', a1+a2+a3)
193 test
.write(['work3', 'aaa.in'], "aaa.in\n")
194 test
.write(['work3', 'bbb.in'], "bbb.in\n")
195 test
.write(['work3', 'ccc.in'], "ccc.in\n")
198 # Test tegular build (i.e. without -k)
199 test
.run(chdir
= 'work3',
204 scons: Reading SConscript files ...
205 scons: done reading SConscript files.
206 scons: Building targets ...
207 %(_python_)s ../fail.py aaa.out
208 scons: building terminated because of errors.
211 test
.must_not_exist(['work3', 'aaa.out'])
212 test
.must_not_exist(['work3', 'bbb.out'])
213 test
.must_not_exist(['work3', 'ccc.out'])
216 test
.run(chdir
= 'work3',
218 test
.must_not_exist(['work3', 'aaa.out'])
219 test
.must_not_exist(['work3', 'bbb.out'])
220 test
.must_not_exist(['work3', 'ccc.out'])
224 test
.run(chdir
= 'work3',
229 scons: Reading SConscript files ...
230 scons: done reading SConscript files.
231 scons: Building targets ...
232 %(_python_)s ../fail.py aaa.out
233 %(_python_)s ../succeed.py bbb.out
234 %(_python_)s ../succeed.py ccc.out
235 scons: done building targets (errors occurred during build).
238 test
.must_not_exist(['work3', 'aaa.out'])
239 test
.must_exist(['work3', 'bbb.out'])
240 test
.must_exist(['work3', 'ccc.out'])
243 test
.run(chdir
= 'work3',
245 test
.must_not_exist(['work3', 'aaa.out'])
246 test
.must_not_exist(['work3', 'bbb.out'])
247 test
.must_not_exist(['work3', 'ccc.out'])
251 test
.run(chdir
= 'work3',
252 arguments
= '--keep-going all',
256 scons: Reading SConscript files ...
257 scons: done reading SConscript files.
258 scons: Building targets ...
259 %(_python_)s ../fail.py aaa.out
260 %(_python_)s ../succeed.py bbb.out
261 %(_python_)s ../succeed.py ccc.out
262 scons: done building targets (errors occurred during build).
265 test
.must_not_exist(['work3', 'aaa.out'])
266 test
.must_exist(['work3', 'bbb.out'])
267 test
.must_exist(['work3', 'ccc.out'])
270 test
.run(chdir
= 'work3',
272 test
.must_not_exist(['work3', 'aaa.out'])
273 test
.must_not_exist(['work3', 'bbb.out'])
274 test
.must_not_exist(['work3', 'ccc.out'])
277 # Separate top-level targets
278 test
.run(chdir
= 'work3',
279 arguments
= '-k a1 a2 a3',
283 scons: Reading SConscript files ...
284 scons: done reading SConscript files.
285 scons: Building targets ...
286 %(_python_)s ../fail.py aaa.out
287 %(_python_)s ../succeed.py bbb.out
288 %(_python_)s ../succeed.py ccc.out
289 scons: done building targets (errors occurred during build).
292 test
.must_not_exist(['work3', 'aaa.out'])
293 test
.must_exist(['work3', 'bbb.out'])
294 test
.must_exist(['work3', 'ccc.out'])
301 # indent-tabs-mode:nil
303 # vim: set expandtab tabstop=4 shiftwidth=4: