]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/core_multifile_actions.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / core_multifile_actions.py
CommitLineData
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
21import BoostBuild
22
11fdf7f2 23t = BoostBuild.Tester(["-d1"], pass_toolset=0)
7c673cae
FG
24
25t.write("file.jam", """
26actions update
27{
28 echo updating $(<)
29}
30
31update x1 x2 ;
32update x2 x3 ;
33""")
34
35# Updating x1 should force x2 to update as well.
36t.run_build_system(["-ffile.jam", "x1"], stdout="""\
37...found 3 targets...
38...updating 3 targets...
39update x1
40updating x1 x2
41update x2
42updating 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.
48t.write("x1", "")
49t.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.
55t.run_build_system(["-ffile.jam", "x3"], stdout="""\
56...found 3 targets...
57...updating 2 targets...
58update x1
59updating x1 x2
60update x2
61updating x2 x3
62...updated 3 targets...
63""")
64
65# Updating x2 should succeed, but x3 should be skipped
66t.rm("x1")
67t.write("file.jam", """\
68actions update
69{
70 echo updating $(<)
71}
72actions fail
73{
74 echo failed $(<)
75 exit 1
76}
77
78update x1 x2 ;
79fail x1 ;
80update x1 x3 ;
81update x2 ;
82update x3 ;
83""")
84
85t.run_build_system(["-ffile.jam", "x3"], status=1, stdout="""\
86...found 3 targets...
87...updating 3 targets...
88update x1
89updating x1 x2
90fail x1
91failed x1
92
93 echo failed x1
94 exit 1
95
96...failed fail x1...
97update x2
98updating 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.
106t.rm("x1")
107t.write("file.jam", """\
108actions update
109{
110 echo updating $(<)
111}
112
113update x1 ;
114update x2 ;
115DEPENDS x2 : x1 ;
116update x2 x3 ;
117""")
118t.run_build_system(["-ffile.jam", "x3"], stdout="""\
119...found 3 targets...
120...updating 3 targets...
121update x1
122updating x1
123update x2
124updating x2
125update x2
126updating 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#
135t.write("file.jam", """\
136actions update
137{
138 echo updating $(<)
139}
140
141targets = x1 x2 ;
142JAM_SEMAPHORE on $(targets) = <s>update_sem ;
143update x1 x2 ;
144""")
145t.run_build_system(["-ffile.jam", "x1"], stdout="""\
146...found 2 targets...
147...updating 2 targets...
148update x1
149updating x1 x2
150...updated 2 targets...
151""")
152
153# A target can appear multiple times in an action
154t.write("file.jam", """\
155actions update
156{
157 echo updating $(<)
158}
159
160update x1 x1 ;
161""")
162t.run_build_system(["-ffile.jam", "x1"], stdout="""\
163...found 1 target...
164...updating 1 target...
165update x1
166updating x1 x1
167...updated 1 target...
168""")
169
170# Together actions should check that all the targets are the same
171# before combining.
172t.write("file.jam", """\
173actions together update
174{
175 echo updating $(<) : $(>)
176}
177
178update x1 x2 : s1 ;
179update x1 x2 : s2 ;
180
181update x3 : s3 ;
182update x3 x4 : s4 ;
183update x4 x3 : s5 ;
184DEPENDS all : x1 x2 x3 x4 ;
185""")
186t.run_build_system(["-ffile.jam"], stdout="""\
187...found 5 targets...
188...updating 4 targets...
189update x1
190updating x1 x2 : s1 s2
191update x3
192updating x3 : s3
193update x3
194updating x3 x4 : s4
195update x4
196updating x4 x3 : s5
197...updated 4 targets...
198""")
199
200
201
202t.cleanup()