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__"
31 _python_ = TestSCons._python_
33 test = TestSCons.TestSCons()
35 test.subdir('work1', 'work2', 'work3')
39 test.write('succeed.py', r"""
41 file = open(sys.argv[1], 'wb')
42 file.write("succeed.py: %s\n" % sys.argv[1])
47 test.write('fail.py', r"""
57 test.write(['work1', 'SConstruct'], """\
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 })
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")
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")
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 Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS')
122 Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS')
123 env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail })
124 env.Fail('aaa.out', 'aaa.in')
125 env.Succeed('bbb.out', 'aaa.out')
126 env.Succeed('ccc.out', 'ccc.in')
127 env.Succeed('ddd.out', 'ccc.in')
130 test.write(['work2', 'aaa.in'], "aaa.in\n")
131 test.write(['work2', 'ccc.in'], "ccc.in\n")
133 test.run(chdir = 'work2',
138 scons: Reading SConscript files ...
139 scons: done reading SConscript files.
140 scons: Building targets ...
141 %(_python_)s ../fail.py aaa.out
142 %(_python_)s ../succeed.py ccc.out
143 %(_python_)s ../succeed.py ddd.out
144 scons: done building targets (errors occurred during build).
147 test.must_not_exist(['work2', 'aaa.out'])
148 test.must_not_exist(['work2', 'bbb.out'])
149 test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n")
150 test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n")
157 # Check that the -k (keep-going) switch works correctly when the Nodes
158 # forms a DAG. The test case is the following
162 # +-----+-----+-------------+
166 # + +---+---+ +---+---+
168 # \ bbb.out / a4 ccc.out
175 test.write(['work3', 'SConstruct'], """\
176 Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS')
177 Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS')
178 env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail })
179 a = env.Fail('aaa.out', 'aaa.in')
180 b = env.Succeed('bbb.out', 'bbb.in')
181 c = env.Succeed('ccc.out', 'ccc.in')
183 a1 = Alias( 'a1', a )
184 a2 = Alias( 'a2', a+b)
186 a3 = Alias( 'a3', a4+c)
188 Alias('all', a1+a2+a3)
191 test.write(['work3', 'aaa.in'], "aaa.in\n")
192 test.write(['work3', 'bbb.in'], "bbb.in\n")
193 test.write(['work3', 'ccc.in'], "ccc.in\n")
196 # Test tegular build (i.e. without -k)
197 test.run(chdir = 'work3',
202 scons: Reading SConscript files ...
203 scons: done reading SConscript files.
204 scons: Building targets ...
205 %(_python_)s ../fail.py aaa.out
206 scons: building terminated because of errors.
209 test.must_not_exist(['work3', 'aaa.out'])
210 test.must_not_exist(['work3', 'bbb.out'])
211 test.must_not_exist(['work3', 'ccc.out'])
214 test.run(chdir = 'work3',
216 test.must_not_exist(['work3', 'aaa.out'])
217 test.must_not_exist(['work3', 'bbb.out'])
218 test.must_not_exist(['work3', 'ccc.out'])
222 test.run(chdir = 'work3',
227 scons: Reading SConscript files ...
228 scons: done reading SConscript files.
229 scons: Building targets ...
230 %(_python_)s ../fail.py aaa.out
231 %(_python_)s ../succeed.py bbb.out
232 %(_python_)s ../succeed.py ccc.out
233 scons: done building targets (errors occurred during build).
236 test.must_not_exist(['work3', 'aaa.out'])
237 test.must_exist(['work3', 'bbb.out'])
238 test.must_exist(['work3', 'ccc.out'])
241 test.run(chdir = 'work3',
243 test.must_not_exist(['work3', 'aaa.out'])
244 test.must_not_exist(['work3', 'bbb.out'])
245 test.must_not_exist(['work3', 'ccc.out'])
249 test.run(chdir = 'work3',
250 arguments = '--keep-going all',
254 scons: Reading SConscript files ...
255 scons: done reading SConscript files.
256 scons: Building targets ...
257 %(_python_)s ../fail.py aaa.out
258 %(_python_)s ../succeed.py bbb.out
259 %(_python_)s ../succeed.py ccc.out
260 scons: done building targets (errors occurred during build).
263 test.must_not_exist(['work3', 'aaa.out'])
264 test.must_exist(['work3', 'bbb.out'])
265 test.must_exist(['work3', 'ccc.out'])
268 test.run(chdir = 'work3',
270 test.must_not_exist(['work3', 'aaa.out'])
271 test.must_not_exist(['work3', 'bbb.out'])
272 test.must_not_exist(['work3', 'ccc.out'])
275 # Separate top-level targets
276 test.run(chdir = 'work3',
277 arguments = '-k a1 a2 a3',
281 scons: Reading SConscript files ...
282 scons: done reading SConscript files.
283 scons: Building targets ...
284 %(_python_)s ../fail.py aaa.out
285 %(_python_)s ../succeed.py bbb.out
286 %(_python_)s ../succeed.py ccc.out
287 scons: done building targets (errors occurred during build).
290 test.must_not_exist(['work3', 'aaa.out'])
291 test.must_exist(['work3', 'bbb.out'])
292 test.must_exist(['work3', 'ccc.out'])
299 # indent-tabs-mode:nil
301 # vim: set expandtab tabstop=4 shiftwidth=4: