summaryrefslogtreecommitdiff
path: root/tools/build/v2/test/conditionals_multiple.py
blob: d58d86c27e0dfa6073f0b8e59eb8df39e3ac8082 (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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#!/usr/bin/python

# Copyright 2008 Jurko Gospodnetic
# 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 properties conditioned on more than one other property work as
# expected.

import BoostBuild


################################################################################
#
# test_multiple_conditions()
# --------------------------
#
################################################################################

def test_multiple_conditions():
    """Basic tests for properties conditioned on multiple other properties.
    """

    t = BoostBuild.Tester("--user-config= --ignore-site-config toolset=testToolset",
        pass_toolset=False, use_test_config=False)

    t.write("testToolset.jam", """
import feature ;
feature.extend toolset : testToolset ;
rule init ( ) { }
""")

    t.write("testToolset.py", """
from b2.build import feature
feature.extend('toolset', ["testToolset"])
def init ( ):
     pass
""")

    t.write("jamroot.jam", """
import feature ;
import notfile ;
import toolset ;

feature.feature description : : free incidental ;
feature.feature aaa : 1 0 : incidental ;
feature.feature bbb : 1 0 : incidental ;
feature.feature ccc : 1 0 : incidental ;

rule buildRule ( name : targets ? : properties * )
{
    for local description in [ feature.get-values description : $(properties) ]
    {
        ECHO "description:" /$(description)/ ;
    }
}

notfile testTarget1 : @buildRule : :
    <description>d
    <aaa>0:<description>a0
    <aaa>1:<description>a1
    <aaa>0,<bbb>0:<description>a0-b0
    <aaa>0,<bbb>1:<description>a0-b1
    <aaa>1,<bbb>0:<description>a1-b0
    <aaa>1,<bbb>1:<description>a1-b1
    <aaa>0,<bbb>0,<ccc>0:<description>a0-b0-c0
    <aaa>0,<bbb>0,<ccc>1:<description>a0-b0-c1
    <aaa>0,<bbb>1,<ccc>1:<description>a0-b1-c1
    <aaa>1,<bbb>0,<ccc>1:<description>a1-b0-c1
    <aaa>1,<bbb>1,<ccc>0:<description>a1-b1-c0
    <aaa>1,<bbb>1,<ccc>1:<description>a1-b1-c1 ;
""")

    t.run_build_system("aaa=1 bbb=1 ccc=1")
    t.expect_output_line("description: /d/"              )
    t.expect_output_line("description: /a0/"      , False)
    t.expect_output_line("description: /a1/"             )
    t.expect_output_line("description: /a0-b0/"   , False)
    t.expect_output_line("description: /a0-b1/"   , False)
    t.expect_output_line("description: /a1-b0/"   , False)
    t.expect_output_line("description: /a1-b1/"          )
    t.expect_output_line("description: /a0-b0-c0/", False)
    t.expect_output_line("description: /a0-b0-c1/", False)
    t.expect_output_line("description: /a0-b1-c1/", False)
    t.expect_output_line("description: /a1-b0-c1/", False)
    t.expect_output_line("description: /a1-b1-c0/", False)
    t.expect_output_line("description: /a1-b1-c1/"       )

    t.run_build_system("aaa=0 bbb=0 ccc=1")
    t.expect_output_line("description: /d/"              )
    t.expect_output_line("description: /a0/"             )
    t.expect_output_line("description: /a1/"      , False)
    t.expect_output_line("description: /a0-b0/"          )
    t.expect_output_line("description: /a0-b1/"   , False)
    t.expect_output_line("description: /a1-b0/"   , False)
    t.expect_output_line("description: /a1-b1/"   , False)
    t.expect_output_line("description: /a0-b0-c0/", False)
    t.expect_output_line("description: /a0-b0-c1/"       )
    t.expect_output_line("description: /a0-b1-c1/", False)
    t.expect_output_line("description: /a1-b0-c1/", False)
    t.expect_output_line("description: /a1-b1-c0/", False)
    t.expect_output_line("description: /a1-b1-c1/", False)

    t.run_build_system("aaa=0 bbb=0 ccc=0")
    t.expect_output_line("description: /d/"              )
    t.expect_output_line("description: /a0/"             )
    t.expect_output_line("description: /a1/"      , False)
    t.expect_output_line("description: /a0-b0/"          )
    t.expect_output_line("description: /a0-b1/"   , False)
    t.expect_output_line("description: /a1-b0/"   , False)
    t.expect_output_line("description: /a1-b1/"   , False)
    t.expect_output_line("description: /a0-b0-c0/"       )
    t.expect_output_line("description: /a0-b0-c1/", False)
    t.expect_output_line("description: /a0-b1-c1/", False)
    t.expect_output_line("description: /a1-b0-c1/", False)
    t.expect_output_line("description: /a1-b1-c0/", False)
    t.expect_output_line("description: /a1-b1-c1/", False)

    t.cleanup()


################################################################################
#
# test_multiple_conditions_with_toolset_version()
# -----------------------------------------------
#
################################################################################

def test_multiple_conditions_with_toolset_version():
    """Regression tests for properties conditioned on the toolset version
    subfeature and some additional properties.
    """

    toolset = "testToolset" ;

    t = BoostBuild.Tester("--user-config= --ignore-site-config", pass_toolset=False, use_test_config=False)

    t.write( toolset + ".jam", """
import feature ;
feature.extend toolset : %(toolset)s ;
feature.subfeature toolset %(toolset)s : version : 0 1 ;
rule init ( version ? ) { }
""" % {"toolset": toolset})

    t.write( "testToolset.py", """
from b2.build import feature
feature.extend('toolset', ["testToolset"])
feature.subfeature('toolset',"testToolset","version",['0','1'])
def init ( version ):
     pass
     """)

    t.write("jamroot.jam", """
import feature ;
import notfile ;
import toolset ;

toolset.using testToolset ;

feature.feature description : : free incidental ;
feature.feature aaa : 0 1 : incidental ;
feature.feature bbb : 0 1 : incidental ;
feature.feature ccc : 0 1 : incidental ;

rule buildRule ( name : targets ? : properties * )
{
    local ttt = [ feature.get-values toolset                     : $(properties) ] ;
    local vvv = [ feature.get-values toolset-testToolset:version : $(properties) ] ;
    local aaa = [ feature.get-values aaa                         : $(properties) ] ;
    local bbb = [ feature.get-values bbb                         : $(properties) ] ;
    local ccc = [ feature.get-values ccc                         : $(properties) ] ;
    ECHO "toolset:" /$(ttt)/ "version:" /$(vvv)/ "aaa/bbb/ccc:" /$(aaa)/$(bbb)/$(ccc)/ ;
    for local description in [ feature.get-values description : $(properties) ]
    {
        ECHO "description:" /$(description)/ ;
    }
}

notfile testTarget1 : @buildRule : :
    <toolset>testToolset,<aaa>0:<description>t-a0
    <toolset>testToolset,<aaa>1:<description>t-a1

    <toolset>testToolset-0,<aaa>0:<description>t0-a0
    <toolset>testToolset-0,<aaa>1:<description>t0-a1
    <toolset>testToolset-1,<aaa>0:<description>t1-a0
    <toolset>testToolset-1,<aaa>1:<description>t1-a1

    <toolset>testToolset,<aaa>0,<bbb>0:<description>t-a0-b0
    <toolset>testToolset,<aaa>0,<bbb>1:<description>t-a0-b1
    <toolset>testToolset,<aaa>1,<bbb>0:<description>t-a1-b0
    <toolset>testToolset,<aaa>1,<bbb>1:<description>t-a1-b1

    <aaa>0,<toolset>testToolset,<bbb>0:<description>a0-t-b0
    <aaa>0,<toolset>testToolset,<bbb>1:<description>a0-t-b1
    <aaa>1,<toolset>testToolset,<bbb>0:<description>a1-t-b0
    <aaa>1,<toolset>testToolset,<bbb>1:<description>a1-t-b1

    <aaa>0,<bbb>0,<toolset>testToolset:<description>a0-b0-t
    <aaa>0,<bbb>1,<toolset>testToolset:<description>a0-b1-t
    <aaa>1,<bbb>0,<toolset>testToolset:<description>a1-b0-t
    <aaa>1,<bbb>1,<toolset>testToolset:<description>a1-b1-t

    <toolset>testToolset-0,<aaa>0,<bbb>0:<description>t0-a0-b0
    <toolset>testToolset-0,<aaa>0,<bbb>1:<description>t0-a0-b1
    <toolset>testToolset-0,<aaa>1,<bbb>0:<description>t0-a1-b0
    <toolset>testToolset-0,<aaa>1,<bbb>1:<description>t0-a1-b1
    <toolset>testToolset-1,<aaa>0,<bbb>0:<description>t1-a0-b0
    <toolset>testToolset-1,<aaa>0,<bbb>1:<description>t1-a0-b1
    <toolset>testToolset-1,<aaa>1,<bbb>0:<description>t1-a1-b0
    <toolset>testToolset-1,<aaa>1,<bbb>1:<description>t1-a1-b1

    <aaa>0,<toolset>testToolset-1,<bbb>0:<description>a0-t1-b0
    <aaa>0,<toolset>testToolset-1,<bbb>1:<description>a0-t1-b1
    <aaa>1,<toolset>testToolset-0,<bbb>0:<description>a1-t0-b0
    <aaa>1,<toolset>testToolset-0,<bbb>1:<description>a1-t0-b1

    <bbb>0,<aaa>1,<toolset>testToolset-0:<description>b0-a1-t0
    <bbb>0,<aaa>0,<toolset>testToolset-1:<description>b0-a0-t1
    <bbb>0,<aaa>1,<toolset>testToolset-1:<description>b0-a1-t1
    <bbb>1,<aaa>0,<toolset>testToolset-1:<description>b1-a0-t1
    <bbb>1,<aaa>1,<toolset>testToolset-0:<description>b1-a1-t0
    <bbb>1,<aaa>1,<toolset>testToolset-1:<description>b1-a1-t1 ;
""")

    t.run_build_system("aaa=1 bbb=1 ccc=1 toolset=%s-0" % toolset)
    t.expect_output_line("description: /t-a0/"    , False)
    t.expect_output_line("description: /t-a1/"           )
    t.expect_output_line("description: /t0-a0/"   , False)
    t.expect_output_line("description: /t0-a1/"          )
    t.expect_output_line("description: /t1-a0/"   , False)
    t.expect_output_line("description: /t1-a1/"   , False)
    t.expect_output_line("description: /t-a0-b0/" , False)
    t.expect_output_line("description: /t-a0-b1/" , False)
    t.expect_output_line("description: /t-a1-b0/" , False)
    t.expect_output_line("description: /t-a1-b1/"        )
    t.expect_output_line("description: /a0-t-b0/" , False)
    t.expect_output_line("description: /a0-t-b1/" , False)
    t.expect_output_line("description: /a1-t-b0/" , False)
    t.expect_output_line("description: /a1-t-b1/"        )
    t.expect_output_line("description: /a0-b0-t/" , False)
    t.expect_output_line("description: /a0-b1-t/" , False)
    t.expect_output_line("description: /a1-b0-t/" , False)
    t.expect_output_line("description: /a1-b1-t/"        )
    t.expect_output_line("description: /t0-a0-b0/", False)
    t.expect_output_line("description: /t0-a0-b1/", False)
    t.expect_output_line("description: /t0-a1-b0/", False)
    t.expect_output_line("description: /t0-a1-b1/"       )
    t.expect_output_line("description: /t1-a0-b0/", False)
    t.expect_output_line("description: /t1-a0-b1/", False)
    t.expect_output_line("description: /t1-a1-b0/", False)
    t.expect_output_line("description: /t1-a1-b1/", False)
    t.expect_output_line("description: /a0-t1-b0/", False)
    t.expect_output_line("description: /a0-t1-b1/", False)
    t.expect_output_line("description: /a1-t0-b0/", False)
    t.expect_output_line("description: /a1-t0-b1/"       )
    t.expect_output_line("description: /b0-a1-t0/", False)
    t.expect_output_line("description: /b0-a0-t1/", False)
    t.expect_output_line("description: /b0-a1-t1/", False)
    t.expect_output_line("description: /b1-a0-t1/", False)
    t.expect_output_line("description: /b1-a1-t0/"       )
    t.expect_output_line("description: /b1-a1-t1/", False)

    t.run_build_system("aaa=1 bbb=1 ccc=1 toolset=%s-1" % toolset)
    t.expect_output_line("description: /t-a0/"    , False)
    t.expect_output_line("description: /t-a1/"           )
    t.expect_output_line("description: /t0-a0/"   , False)
    t.expect_output_line("description: /t0-a1/"   , False)
    t.expect_output_line("description: /t1-a0/"   , False)
    t.expect_output_line("description: /t1-a1/"          )
    t.expect_output_line("description: /t-a0-b0/" , False)
    t.expect_output_line("description: /t-a0-b1/" , False)
    t.expect_output_line("description: /t-a1-b0/" , False)
    t.expect_output_line("description: /t-a1-b1/"        )
    t.expect_output_line("description: /a0-t-b0/" , False)
    t.expect_output_line("description: /a0-t-b1/" , False)
    t.expect_output_line("description: /a1-t-b0/" , False)
    t.expect_output_line("description: /a1-t-b1/"        )
    t.expect_output_line("description: /a0-b0-t/" , False)
    t.expect_output_line("description: /a0-b1-t/" , False)
    t.expect_output_line("description: /a1-b0-t/" , False)
    t.expect_output_line("description: /a1-b1-t/"        )
    t.expect_output_line("description: /t0-a0-b0/", False)
    t.expect_output_line("description: /t0-a0-b1/", False)
    t.expect_output_line("description: /t0-a1-b0/", False)
    t.expect_output_line("description: /t0-a1-b1/", False)
    t.expect_output_line("description: /t1-a0-b0/", False)
    t.expect_output_line("description: /t1-a0-b1/", False)
    t.expect_output_line("description: /t1-a1-b0/", False)
    t.expect_output_line("description: /t1-a1-b1/"       )
    t.expect_output_line("description: /a0-t1-b0/", False)
    t.expect_output_line("description: /a0-t1-b1/", False)
    t.expect_output_line("description: /a1-t0-b0/", False)
    t.expect_output_line("description: /a1-t0-b1/", False)
    t.expect_output_line("description: /b0-a1-t0/", False)
    t.expect_output_line("description: /b0-a0-t1/", False)
    t.expect_output_line("description: /b0-a1-t1/", False)
    t.expect_output_line("description: /b1-a0-t1/", False)
    t.expect_output_line("description: /b1-a1-t0/", False)
    t.expect_output_line("description: /b1-a1-t1/"       )

    t.cleanup()


################################################################################
#
# main()
# ------
#
################################################################################

test_multiple_conditions()
test_multiple_conditions_with_toolset_version()