summaryrefslogtreecommitdiff
path: root/tools/build/test/core_multifile_actions.py
blob: a9c7f4790c8ce9770312a33986bc47793aa471fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/python

# Copyright 2013 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

#   Tests that actions that produce multiple targets are handled
# correctly.  The rules are as follows:
#
# - If any action that updates a target is run, then the target
#   is considered to be out-of-date and all of its updating actions
#   are run in order.
# - A target is considered updated when all of its updating actions
#   have completed successfully.
# - If any updating action for a target fails, then the remaining
#   actions are skipped and the target is marked as failed.
#
# Note that this is a more thorough test case for the same
# problem that core_parallel_multifile_actions_N.py checks for.

import BoostBuild

t = BoostBuild.Tester(["-d1"], pass_toolset=0)

t.write("file.jam", """
actions update
{
    echo updating $(<)
}

update x1 x2 ;
update x2 x3 ;
""")

# Updating x1 should force x2 to update as well.
t.run_build_system(["-ffile.jam", "x1"], stdout="""\
...found 3 targets...
...updating 3 targets...
update x1
updating x1 x2
update x2
updating x2 x3
...updated 3 targets...
""")

# If x1 is up-to-date, we don't need to update x2,
# even though x2 is missing.
t.write("x1", "")
t.run_build_system(["-ffile.jam", "x1"], stdout="""\
...found 1 target...
""")

# Building x3 should update x1 and x2, even though
# x1 would be considered up-to-date, taken alone.
t.run_build_system(["-ffile.jam", "x3"], stdout="""\
...found 3 targets...
...updating 2 targets...
update x1
updating x1 x2
update x2
updating x2 x3
...updated 3 targets...
""")

# Updating x2 should succeed, but x3 should be skipped
t.rm("x1")
t.write("file.jam", """\
actions update
{
    echo updating $(<)
}
actions fail
{
    echo failed $(<)
    exit 1
}

update x1 x2 ;
fail x1 ;
update x1 x3 ;
update x2 ;
update x3 ;
""")

t.run_build_system(["-ffile.jam", "x3"], status=1, stdout="""\
...found 3 targets...
...updating 3 targets...
update x1
updating x1 x2
fail x1
failed x1

    echo failed x1
    exit 1

...failed fail x1...
update x2
updating x2
...failed updating 2 targets...
...updated 1 target...
""")

# Make sure that dependencies of targets that are
# updated as a result of a multifile action are
# processed correctly.
t.rm("x1")
t.write("file.jam", """\
actions update
{
    echo updating $(<)
}

update x1 ;
update x2 ;
DEPENDS x2 : x1 ;
update x2 x3 ;
""")
t.run_build_system(["-ffile.jam", "x3"], stdout="""\
...found 3 targets...
...updating 3 targets...
update x1
updating x1
update x2
updating x2
update x2
updating x2 x3
...updated 3 targets...
""")

# JAM_SEMAPHORE rules:
#
# - if two updating actions have targets that share a semaphore,
#   these actions cannot be run in parallel.
#
t.write("file.jam", """\
actions update
{
    echo updating $(<)
}

targets = x1 x2 ;
JAM_SEMAPHORE on $(targets) = <s>update_sem ;
update x1 x2 ;
""")
t.run_build_system(["-ffile.jam", "x1"], stdout="""\
...found 2 targets...
...updating 2 targets...
update x1
updating x1 x2
...updated 2 targets...
""")

# A target can appear multiple times in an action
t.write("file.jam", """\
actions update
{
    echo updating $(<)
}

update x1 x1 ;
""")
t.run_build_system(["-ffile.jam", "x1"], stdout="""\
...found 1 target...
...updating 1 target...
update x1
updating x1 x1
...updated 1 target...
""")

# Together actions should check that all the targets are the same
# before combining.
t.write("file.jam", """\
actions together update
{
    echo updating $(<) : $(>)
}

update x1 x2 : s1 ;
update x1 x2 : s2 ;

update x3 : s3 ;
update x3 x4 : s4 ;
update x4 x3 : s5 ;
DEPENDS all : x1 x2 x3 x4 ;
""")
t.run_build_system(["-ffile.jam"], stdout="""\
...found 5 targets...
...updating 4 targets...
update x1
updating x1 x2 : s1 s2
update x3
updating x3 : s3
update x3
updating x3 x4 : s4
update x4
updating x4 x3 : s5
...updated 4 targets...
""")



t.cleanup()