]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2011 Steven Watanabe | |
4 | # Distributed under the Boost Software License, Version 1.0. | |
5 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | import BoostBuild | |
8 | import os | |
9 | ||
10 | ||
11 | def basic(): | |
11fdf7f2 | 12 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
13 | |
14 | t.write("file.jam", """\ | |
15 | actions do-print | |
16 | { | |
17 | echo updating $(<) | |
18 | } | |
19 | ||
20 | NOTFILE target1 ; | |
21 | ALWAYS target1 ; | |
22 | do-print target1 ; | |
23 | ||
24 | UPDATE_NOW target1 ; | |
25 | ||
26 | DEPENDS all : target1 ; | |
27 | """) | |
28 | ||
29 | t.run_build_system(["-ffile.jam"], stdout="""\ | |
30 | ...found 1 target... | |
31 | ...updating 1 target... | |
32 | do-print target1 | |
33 | updating target1 | |
34 | ...updated 1 target... | |
35 | ...found 1 target... | |
36 | """) | |
37 | ||
38 | t.cleanup() | |
39 | ||
40 | ||
41 | def ignore_minus_n(): | |
11fdf7f2 | 42 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
43 | |
44 | t.write("file.jam", """\ | |
45 | actions do-print | |
46 | { | |
47 | echo updating $(<) | |
48 | } | |
49 | ||
50 | NOTFILE target1 ; | |
51 | ALWAYS target1 ; | |
52 | do-print target1 ; | |
53 | ||
54 | UPDATE_NOW target1 : : ignore-minus-n ; | |
55 | ||
56 | DEPENDS all : target1 ; | |
57 | """) | |
58 | ||
59 | t.run_build_system(["-ffile.jam", "-n"], stdout="""\ | |
60 | ...found 1 target... | |
61 | ...updating 1 target... | |
62 | do-print target1 | |
63 | ||
64 | echo updating target1 | |
65 | ||
66 | updating target1 | |
67 | ...updated 1 target... | |
68 | ...found 1 target... | |
69 | """) | |
70 | ||
71 | t.cleanup() | |
72 | ||
73 | ||
74 | def failed_target(): | |
11fdf7f2 | 75 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
76 | |
77 | t.write("file.jam", """\ | |
78 | actions fail | |
79 | { | |
80 | exit 1 | |
81 | } | |
82 | ||
83 | NOTFILE target1 ; | |
84 | ALWAYS target1 ; | |
85 | fail target1 ; | |
86 | ||
87 | actions do-print | |
88 | { | |
89 | echo updating $(<) | |
90 | } | |
91 | ||
92 | NOTFILE target2 ; | |
93 | do-print target2 ; | |
94 | DEPENDS target2 : target1 ; | |
95 | ||
96 | UPDATE_NOW target1 : : ignore-minus-n ; | |
97 | ||
98 | DEPENDS all : target1 target2 ; | |
99 | """) | |
100 | ||
101 | t.run_build_system(["-ffile.jam", "-n"], stdout="""\ | |
102 | ...found 1 target... | |
103 | ...updating 1 target... | |
104 | fail target1 | |
105 | ||
106 | exit 1 | |
107 | ||
108 | ...failed fail target1... | |
109 | ...failed updating 1 target... | |
110 | ...found 2 targets... | |
111 | ...updating 1 target... | |
112 | do-print target2 | |
113 | ||
114 | echo updating target2 | |
115 | ||
116 | ...updated 1 target... | |
117 | """) | |
118 | ||
119 | t.cleanup() | |
120 | ||
121 | ||
122 | def missing_target(): | |
11fdf7f2 | 123 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
124 | |
125 | t.write("file.jam", """\ | |
126 | actions do-print | |
127 | { | |
128 | echo updating $(<) | |
129 | } | |
130 | ||
131 | NOTFILE target2 ; | |
132 | do-print target2 ; | |
133 | DEPENDS target2 : target1 ; | |
134 | ||
135 | UPDATE_NOW target1 : : ignore-minus-n ; | |
136 | ||
137 | DEPENDS all : target1 target2 ; | |
138 | """) | |
139 | ||
140 | t.run_build_system(["-ffile.jam", "-n"], status=1, stdout="""\ | |
141 | don't know how to make target1 | |
142 | ...found 1 target... | |
143 | ...can't find 1 target... | |
144 | ...found 2 targets... | |
145 | ...can't make 1 target... | |
146 | """) | |
147 | ||
148 | t.cleanup() | |
149 | ||
150 | ||
151 | def build_once(): | |
152 | """ | |
153 | Make sure that if we call UPDATE_NOW with ignore-minus-n, the target gets | |
154 | updated exactly once regardless of previous calls to UPDATE_NOW with -n in | |
155 | effect. | |
156 | ||
157 | """ | |
11fdf7f2 | 158 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
159 | |
160 | t.write("file.jam", """\ | |
161 | actions do-print | |
162 | { | |
163 | echo updating $(<) | |
164 | } | |
165 | ||
166 | NOTFILE target1 ; | |
167 | ALWAYS target1 ; | |
168 | do-print target1 ; | |
169 | ||
170 | UPDATE_NOW target1 ; | |
171 | UPDATE_NOW target1 : : ignore-minus-n ; | |
172 | UPDATE_NOW target1 : : ignore-minus-n ; | |
173 | ||
174 | DEPENDS all : target1 ; | |
175 | """) | |
176 | ||
177 | t.run_build_system(["-ffile.jam", "-n"], stdout="""\ | |
178 | ...found 1 target... | |
179 | ...updating 1 target... | |
180 | do-print target1 | |
181 | ||
182 | echo updating target1 | |
183 | ||
184 | ...updated 1 target... | |
185 | do-print target1 | |
186 | ||
187 | echo updating target1 | |
188 | ||
189 | updating target1 | |
190 | ...updated 1 target... | |
191 | ...found 1 target... | |
192 | """) | |
193 | ||
194 | t.cleanup() | |
195 | ||
196 | ||
197 | def return_status(): | |
198 | """ | |
199 | Make sure that UPDATE_NOW returns a failure status if | |
200 | the target failed in a previous call to UPDATE_NOW | |
201 | """ | |
11fdf7f2 | 202 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
203 | |
204 | t.write("file.jam", """\ | |
205 | actions fail | |
206 | { | |
207 | exit 1 | |
208 | } | |
209 | ||
210 | NOTFILE target1 ; | |
211 | ALWAYS target1 ; | |
212 | fail target1 ; | |
213 | ||
11fdf7f2 TL |
214 | ECHO "update1:" [ UPDATE_NOW target1 ] ; |
215 | ECHO "update2:" [ UPDATE_NOW target1 ] ; | |
7c673cae FG |
216 | |
217 | DEPENDS all : target1 ; | |
218 | """) | |
219 | ||
220 | t.run_build_system(["-ffile.jam"], status=1, stdout="""\ | |
221 | ...found 1 target... | |
222 | ...updating 1 target... | |
223 | fail target1 | |
224 | ||
225 | exit 1 | |
226 | ||
227 | ...failed fail target1... | |
228 | ...failed updating 1 target... | |
229 | update1: | |
230 | update2: | |
231 | ...found 1 target... | |
232 | """) | |
233 | ||
234 | t.cleanup() | |
235 | ||
236 | ||
237 | def save_restore(): | |
238 | """Tests that ignore-minus-n and ignore-minus-q are | |
239 | local to the call to UPDATE_NOW""" | |
11fdf7f2 | 240 | t = BoostBuild.Tester(pass_toolset=0) |
7c673cae FG |
241 | |
242 | t.write("actions.jam", """\ | |
243 | rule fail | |
244 | { | |
245 | NOTFILE $(<) ; | |
246 | ALWAYS $(<) ; | |
247 | } | |
248 | actions fail | |
249 | { | |
250 | exit 1 | |
251 | } | |
252 | ||
253 | rule pass | |
254 | { | |
255 | NOTFILE $(<) ; | |
256 | ALWAYS $(<) ; | |
257 | } | |
258 | actions pass | |
259 | { | |
260 | echo updating $(<) | |
261 | } | |
262 | """) | |
263 | t.write("file.jam", """ | |
264 | include actions.jam ; | |
265 | fail target1 ; | |
266 | fail target2 ; | |
267 | UPDATE_NOW target1 target2 : : $(IGNORE_MINUS_N) : $(IGNORE_MINUS_Q) ; | |
268 | fail target3 ; | |
269 | fail target4 ; | |
270 | UPDATE_NOW target3 target4 ; | |
271 | UPDATE ; | |
272 | """) | |
273 | t.run_build_system(['-n', '-sIGNORE_MINUS_N=1', '-ffile.jam'], | |
274 | stdout='''...found 2 targets... | |
275 | ...updating 2 targets... | |
276 | fail target1 | |
277 | ||
278 | exit 1 | |
279 | ||
280 | ...failed fail target1... | |
281 | fail target2 | |
282 | ||
283 | exit 1 | |
284 | ||
285 | ...failed fail target2... | |
286 | ...failed updating 2 targets... | |
287 | ...found 2 targets... | |
288 | ...updating 2 targets... | |
289 | fail target3 | |
290 | ||
291 | exit 1 | |
292 | ||
293 | fail target4 | |
294 | ||
295 | exit 1 | |
296 | ||
297 | ...updated 2 targets... | |
298 | ''') | |
299 | ||
300 | t.run_build_system(['-q', '-sIGNORE_MINUS_N=1', '-ffile.jam'], | |
301 | status=1, stdout='''...found 2 targets... | |
302 | ...updating 2 targets... | |
303 | fail target1 | |
304 | ||
305 | exit 1 | |
306 | ||
307 | ...failed fail target1... | |
308 | ...failed updating 1 target... | |
309 | ...found 2 targets... | |
310 | ...updating 2 targets... | |
311 | fail target3 | |
312 | ||
313 | exit 1 | |
314 | ||
315 | ...failed fail target3... | |
316 | ...failed updating 1 target... | |
317 | ''') | |
318 | ||
319 | t.run_build_system(['-n', '-sIGNORE_MINUS_Q=1', '-ffile.jam'], | |
320 | stdout='''...found 2 targets... | |
321 | ...updating 2 targets... | |
322 | fail target1 | |
323 | ||
324 | exit 1 | |
325 | ||
326 | fail target2 | |
327 | ||
328 | exit 1 | |
329 | ||
330 | ...updated 2 targets... | |
331 | ...found 2 targets... | |
332 | ...updating 2 targets... | |
333 | fail target3 | |
334 | ||
335 | exit 1 | |
336 | ||
337 | fail target4 | |
338 | ||
339 | exit 1 | |
340 | ||
341 | ...updated 2 targets... | |
342 | ''') | |
343 | ||
344 | t.run_build_system(['-q', '-sIGNORE_MINUS_Q=1', '-ffile.jam'], | |
345 | status=1, stdout='''...found 2 targets... | |
346 | ...updating 2 targets... | |
347 | fail target1 | |
348 | ||
349 | exit 1 | |
350 | ||
351 | ...failed fail target1... | |
352 | fail target2 | |
353 | ||
354 | exit 1 | |
355 | ||
356 | ...failed fail target2... | |
357 | ...failed updating 2 targets... | |
358 | ...found 2 targets... | |
359 | ...updating 2 targets... | |
360 | fail target3 | |
361 | ||
362 | exit 1 | |
363 | ||
364 | ...failed fail target3... | |
365 | ...failed updating 1 target... | |
366 | ''') | |
367 | ||
368 | t.cleanup() | |
369 | ||
370 | ||
371 | basic() | |
372 | ignore_minus_n() | |
373 | failed_target() | |
374 | missing_target() | |
375 | build_once() | |
376 | return_status() | |
377 | save_restore() |