]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2013 Steven Watanabe | |
4 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 | 5 | # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) |
7c673cae FG |
6 | |
7 | # Tests that actions that produce multiple targets are handled | |
8 | # correctly. The rules are as follows: | |
9 | # | |
10 | # - If any action that updates a target is run, then the target | |
11 | # is considered to be out-of-date and all of its updating actions | |
12 | # are run in order. | |
13 | # - A target is considered updated when all of its updating actions | |
14 | # have completed successfully. | |
15 | # - If any updating action for a target fails, then the remaining | |
16 | # actions are skipped and the target is marked as failed. | |
17 | # | |
18 | # Note that this is a more thorough test case for the same | |
19 | # problem that core_parallel_multifile_actions_N.py checks for. | |
20 | ||
21 | import BoostBuild | |
22 | ||
11fdf7f2 | 23 | t = BoostBuild.Tester(["-d1"], pass_toolset=0) |
7c673cae FG |
24 | |
25 | t.write("file.jam", """ | |
26 | actions update | |
27 | { | |
28 | echo updating $(<) | |
29 | } | |
30 | ||
31 | update x1 x2 ; | |
32 | update x2 x3 ; | |
33 | """) | |
34 | ||
35 | # Updating x1 should force x2 to update as well. | |
36 | t.run_build_system(["-ffile.jam", "x1"], stdout="""\ | |
37 | ...found 3 targets... | |
38 | ...updating 3 targets... | |
39 | update x1 | |
40 | updating x1 x2 | |
41 | update x2 | |
42 | updating x2 x3 | |
43 | ...updated 3 targets... | |
44 | """) | |
45 | ||
46 | # If x1 is up-to-date, we don't need to update x2, | |
47 | # even though x2 is missing. | |
48 | t.write("x1", "") | |
49 | t.run_build_system(["-ffile.jam", "x1"], stdout="""\ | |
50 | ...found 1 target... | |
51 | """) | |
52 | ||
53 | # Building x3 should update x1 and x2, even though | |
54 | # x1 would be considered up-to-date, taken alone. | |
55 | t.run_build_system(["-ffile.jam", "x3"], stdout="""\ | |
56 | ...found 3 targets... | |
57 | ...updating 2 targets... | |
58 | update x1 | |
59 | updating x1 x2 | |
60 | update x2 | |
61 | updating x2 x3 | |
62 | ...updated 3 targets... | |
63 | """) | |
64 | ||
65 | # Updating x2 should succeed, but x3 should be skipped | |
66 | t.rm("x1") | |
67 | t.write("file.jam", """\ | |
68 | actions update | |
69 | { | |
70 | echo updating $(<) | |
71 | } | |
72 | actions fail | |
73 | { | |
74 | echo failed $(<) | |
75 | exit 1 | |
76 | } | |
77 | ||
78 | update x1 x2 ; | |
79 | fail x1 ; | |
80 | update x1 x3 ; | |
81 | update x2 ; | |
82 | update x3 ; | |
83 | """) | |
84 | ||
85 | t.run_build_system(["-ffile.jam", "x3"], status=1, stdout="""\ | |
86 | ...found 3 targets... | |
87 | ...updating 3 targets... | |
88 | update x1 | |
89 | updating x1 x2 | |
90 | fail x1 | |
91 | failed x1 | |
92 | ||
93 | echo failed x1 | |
94 | exit 1 | |
95 | ||
96 | ...failed fail x1... | |
97 | update x2 | |
98 | updating x2 | |
99 | ...failed updating 2 targets... | |
100 | ...updated 1 target... | |
101 | """) | |
102 | ||
103 | # Make sure that dependencies of targets that are | |
104 | # updated as a result of a multifile action are | |
105 | # processed correctly. | |
106 | t.rm("x1") | |
107 | t.write("file.jam", """\ | |
108 | actions update | |
109 | { | |
110 | echo updating $(<) | |
111 | } | |
112 | ||
113 | update x1 ; | |
114 | update x2 ; | |
115 | DEPENDS x2 : x1 ; | |
116 | update x2 x3 ; | |
117 | """) | |
118 | t.run_build_system(["-ffile.jam", "x3"], stdout="""\ | |
119 | ...found 3 targets... | |
120 | ...updating 3 targets... | |
121 | update x1 | |
122 | updating x1 | |
123 | update x2 | |
124 | updating x2 | |
125 | update x2 | |
126 | updating x2 x3 | |
127 | ...updated 3 targets... | |
128 | """) | |
129 | ||
130 | # JAM_SEMAPHORE rules: | |
131 | # | |
132 | # - if two updating actions have targets that share a semaphore, | |
133 | # these actions cannot be run in parallel. | |
134 | # | |
135 | t.write("file.jam", """\ | |
136 | actions update | |
137 | { | |
138 | echo updating $(<) | |
139 | } | |
140 | ||
141 | targets = x1 x2 ; | |
142 | JAM_SEMAPHORE on $(targets) = <s>update_sem ; | |
143 | update x1 x2 ; | |
144 | """) | |
145 | t.run_build_system(["-ffile.jam", "x1"], stdout="""\ | |
146 | ...found 2 targets... | |
147 | ...updating 2 targets... | |
148 | update x1 | |
149 | updating x1 x2 | |
150 | ...updated 2 targets... | |
151 | """) | |
152 | ||
153 | # A target can appear multiple times in an action | |
154 | t.write("file.jam", """\ | |
155 | actions update | |
156 | { | |
157 | echo updating $(<) | |
158 | } | |
159 | ||
160 | update x1 x1 ; | |
161 | """) | |
162 | t.run_build_system(["-ffile.jam", "x1"], stdout="""\ | |
163 | ...found 1 target... | |
164 | ...updating 1 target... | |
165 | update x1 | |
166 | updating x1 x1 | |
167 | ...updated 1 target... | |
168 | """) | |
169 | ||
170 | # Together actions should check that all the targets are the same | |
171 | # before combining. | |
172 | t.write("file.jam", """\ | |
173 | actions together update | |
174 | { | |
175 | echo updating $(<) : $(>) | |
176 | } | |
177 | ||
178 | update x1 x2 : s1 ; | |
179 | update x1 x2 : s2 ; | |
180 | ||
181 | update x3 : s3 ; | |
182 | update x3 x4 : s4 ; | |
183 | update x4 x3 : s5 ; | |
184 | DEPENDS all : x1 x2 x3 x4 ; | |
185 | """) | |
186 | t.run_build_system(["-ffile.jam"], stdout="""\ | |
187 | ...found 5 targets... | |
188 | ...updating 4 targets... | |
189 | update x1 | |
190 | updating x1 x2 : s1 s2 | |
191 | update x3 | |
192 | updating x3 : s3 | |
193 | update x3 | |
194 | updating x3 x4 : s4 | |
195 | update x4 | |
196 | updating x4 x3 : s5 | |
197 | ...updated 4 targets... | |
198 | """) | |
199 | ||
200 | ||
201 | ||
202 | t.cleanup() |