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
|
#!/usr/bin/python
# Copyright 2008 Jurko Gospodnetic
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Test that the expected default toolset is used when no toolset is explicitly
# specified on the command line or used from code via the using rule. Test that
# the default toolset is correctly used just like any other explicitly used
# toolset (e.g. toolset prerequisites, properties conditioned on toolset
# related features, etc.).
#
# Note that we need to ignore regular site/user/test configuration files to
# avoid them marking any toolsets not under our control as used.
import BoostBuild
# Line displayed by Boost Build when using the default toolset.
configuring_default_toolset_message = \
'warning: Configuring default toolset "%s".'
###############################################################################
#
# test_conditions_on_default_toolset()
# ------------------------------------
#
###############################################################################
def test_conditions_on_default_toolset():
"""Test that toolset and toolset subfeature conditioned properties get
applied correctly when the toolset is selected by default. Implicitly tests
that we can use the set-default-toolset rule to set the default toolset to
be used by Boost Build.
"""
t = BoostBuild.Tester("--user-config= --ignore-site-config",
pass_toolset=False, use_test_config=False)
toolset_name = "myCustomTestToolset"
toolset_version = "v"
toolset_version_unused = "v_unused"
message_loaded = "Toolset '%s' loaded." % toolset_name
message_initialized = "Toolset '%s' initialized." % toolset_name ;
# Custom toolset.
t.write(toolset_name + ".jam", """
import feature ;
ECHO "%(message_loaded)s" ;
feature.extend toolset : %(toolset_name)s ;
feature.subfeature toolset %(toolset_name)s : version : %(toolset_version)s %(toolset_version_unused)s ;
rule init ( version ) { ECHO "%(message_initialized)s" ; }
""" % {'message_loaded' : message_loaded ,
'message_initialized' : message_initialized,
'toolset_name' : toolset_name ,
'toolset_version' : toolset_version ,
'toolset_version_unused': toolset_version_unused})
# Main Boost Build project script.
t.write("jamroot.jam", """
import build-system ;
import errors ;
import feature ;
import notfile ;
build-system.set-default-toolset %(toolset_name)s : %(toolset_version)s ;
feature.feature description : : free incidental ;
# We use a rule instead of an action to avoid problems with action output not
# getting piped to stdout by the testing system.
rule buildRule ( names : targets ? : properties * )
{
local descriptions = [ feature.get-values description : $(properties) ] ;
ECHO "descriptions:" /$(descriptions)/ ;
local toolset = [ feature.get-values toolset : $(properties) ] ;
ECHO "toolset:" /$(toolset)/ ;
local toolset-version = [ feature.get-values "toolset-$(toolset):version" : $(properties) ] ;
ECHO "toolset-version:" /$(toolset-version)/ ;
}
notfile testTarget
: @buildRule
:
:
<description>stand-alone
<toolset>%(toolset_name)s:<description>toolset
<toolset>%(toolset_name)s-%(toolset_version)s:<description>toolset-version
<toolset>%(toolset_name)s-%(toolset_version_unused)s:<description>toolset-version-unused ;
""" % {'toolset_name' : toolset_name ,
'toolset_version' : toolset_version,
'toolset_version_unused': toolset_version_unused})
t.run_build_system()
t.expect_output_lines(configuring_default_toolset_message % toolset_name)
t.expect_output_lines(message_loaded)
t.expect_output_lines(message_initialized)
t.expect_output_lines("descriptions: /stand-alone/ /toolset/ "
"/toolset-version/")
t.expect_output_lines("toolset: /%s/" % toolset_name)
t.expect_output_lines("toolset-version: /%s/" % toolset_version)
t.cleanup()
###############################################################################
#
# test_default_toolset_on_os()
# ----------------------------
#
###############################################################################
def test_default_toolset_on_os( os, expected_toolset ):
"""Test that the given toolset is used as the default toolset on the given
os. Uses hardcoded knowledge of how Boost Build decides on which host OS it
is currently running. Note that we must not do much after tricking Boost
Build into believing it has a specific host OS as this might mess up other
important internal Boost Build state.
"""
t = BoostBuild.Tester("--user-config= --ignore-site-config",
pass_toolset=False, use_test_config=False)
t.write("jamroot.jam", "modules.poke os : .name : %s ;" % os)
# We need to tell the test system to ignore stderr output as attempting to
# load missing toolsets might cause random failures with which we are not
# concerned in this test.
t.run_build_system(stderr=None)
t.expect_output_lines(configuring_default_toolset_message %
expected_toolset)
t.cleanup()
###############################################################################
#
# test_default_toolset_requirements()
# -----------------------------------
#
###############################################################################
def test_default_toolset_requirements():
"""Test that default toolset's requirements get applied correctly.
"""
t = BoostBuild.Tester("--user-config= --ignore-site-config",
pass_toolset=False, use_test_config=False,
ignore_toolset_requirements=False)
toolset_name = "customTestToolsetWithRequirements"
# Custom toolset.
t.write(toolset_name + ".jam", """
import feature ;
import toolset ;
feature.extend toolset : %(toolset_name)s ;
toolset.add-requirements <description>toolset-requirement ;
rule init ( ) { }
""" % {'toolset_name': toolset_name})
# Main Boost Build project script.
t.write("jamroot.jam", """
import build-system ;
import errors ;
import feature ;
import notfile ;
build-system.set-default-toolset %(toolset_name)s ;
feature.feature description : : free incidental ;
# We use a rule instead of an action to avoid problems with action output not
# getting piped to stdout by the testing system.
rule buildRule ( names : targets ? : properties * )
{
local descriptions = [ feature.get-values description : $(properties) ] ;
ECHO "descriptions:" /$(descriptions)/ ;
local toolset = [ feature.get-values toolset : $(properties) ] ;
ECHO "toolset:" /$(toolset)/ ;
}
notfile testTarget
: @buildRule
:
:
<description>target-requirement
<description>toolset-requirement:<description>conditioned-requirement
<description>unrelated-condition:<description>unrelated-description ;
""" % {'toolset_name': toolset_name})
t.run_build_system()
t.expect_output_lines(configuring_default_toolset_message % toolset_name)
t.expect_output_lines("descriptions: /conditioned-requirement/ "
"/target-requirement/ /toolset-requirement/")
t.expect_output_lines("toolset: /%s/" % toolset_name)
t.cleanup()
###############################################################################
#
# main()
# ------
#
###############################################################################
test_default_toolset_on_os("NT" , "msvc")
test_default_toolset_on_os("LINUX" , "gcc" )
test_default_toolset_on_os("CYGWIN" , "gcc" )
test_default_toolset_on_os("SomeOtherOS", "gcc" )
test_default_toolset_requirements()
test_conditions_on_default_toolset()
|