]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2003 Vladimir Prus | |
4 | # Distributed under the Boost Software License, Version 1.0. | |
5 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | ||
8 | import BoostBuild | |
9 | ||
92f5a8d4 TL |
10 | t = BoostBuild.Tester(arguments=["--config="], pass_toolset=0) |
11 | ||
12 | t.write("source.input", "") | |
13 | ||
14 | t.write("test-properties.jam", """ | |
15 | import feature : feature ; | |
16 | import generators ; | |
17 | import toolset ; | |
18 | import type ; | |
19 | ||
20 | # We're not using the toolset at all, and we want to | |
21 | # suppress toolset initialization to avoid surprises. | |
22 | feature.extend toolset : null ; | |
23 | ||
24 | type.register CHECK : check ; | |
25 | type.register INPUT : input ; | |
26 | feature expected-define : : free ; | |
27 | feature unexpected-define : : free ; | |
28 | toolset.flags test-properties DEFINES : <define> ; | |
29 | toolset.flags test-properties EXPECTED : <expected-define> ; | |
30 | toolset.flags test-properties UNEXPECTED : <unexpected-define> ; | |
31 | generators.register-standard test-properties.check : INPUT : CHECK ; | |
32 | rule check ( target : source : properties * ) | |
33 | { | |
34 | local defines = [ on $(target) return $(DEFINES) ] ; | |
35 | for local macro in [ on $(target) return $(EXPECTED) ] | |
36 | { | |
37 | if ! ( $(macro) in $(defines) ) | |
38 | { | |
39 | EXIT expected $(macro) for $(target) in $(properties) : 1 ; | |
40 | } | |
41 | } | |
42 | for local macro in [ on $(target) return $(UNEXPECTED) ] | |
43 | { | |
44 | if $(macro) in $(defines) | |
45 | { | |
46 | EXIT unexpected $(macro) for $(target) in $(properties) : 1 ; | |
47 | } | |
48 | } | |
49 | } | |
50 | actions check | |
51 | { | |
52 | echo okay > $(<) | |
53 | } | |
11fdf7f2 TL |
54 | """) |
55 | ||
7c673cae | 56 | t.write("jamfile.jam", """ |
92f5a8d4 | 57 | import test-properties ; |
7c673cae FG |
58 | # See if default value of composite feature 'cf' will be expanded to |
59 | # <define>CF_IS_OFF. | |
92f5a8d4 | 60 | check a : source.input : <expected-define>CF_IS_OFF ; |
7c673cae FG |
61 | |
62 | # See if subfeature in requirements in expanded. | |
92f5a8d4 TL |
63 | check b : source.input : <cf>on-1 |
64 | <expected-define>CF_1 <unexpected-define>CF_IS_OFF ; | |
7c673cae FG |
65 | |
66 | # See if conditional requirements are recursively expanded. | |
92f5a8d4 TL |
67 | check c : source.input : <toolset>null:<variant>release |
68 | <variant>release:<define>FOO <expected-define>FOO | |
7c673cae | 69 | ; |
11fdf7f2 TL |
70 | |
71 | # Composites specified in the default build should not | |
72 | # be expanded if they are overridden in the the requirements. | |
92f5a8d4 | 73 | check d : source.input : <cf>on <unexpected-define>CF_IS_OFF : <cf>off ; |
11fdf7f2 TL |
74 | |
75 | # Overriding a feature should clear subfeatures and | |
76 | # apply default values of subfeatures. | |
92f5a8d4 TL |
77 | check e : source.input : <cf>always |
78 | <unexpected-define>CF_IS_OFF <expected-define>CF_2 <unexpected-define>CF_1 | |
79 | : <cf>on-1 ; | |
11fdf7f2 TL |
80 | |
81 | # Subfeatures should not be changed if the parent feature doesn't change | |
92f5a8d4 | 82 | check f : source.input : <cf>on <expected-define>CF_1 : <cf>on-1 ; |
11fdf7f2 TL |
83 | |
84 | # If a subfeature is not specific to the value of the parent feature, | |
85 | # then changing the parent value should not clear the subfeature. | |
92f5a8d4 | 86 | check g : source.input : <fopt>off <expected-define>FOPT_2 : <fopt>on-2 ; |
11fdf7f2 TL |
87 | |
88 | # If the default value of a composite feature adds an optional | |
89 | # feature which has a subfeature with a default, then that | |
90 | # default should be added. | |
92f5a8d4 TL |
91 | check h : source.input : <expected-define>CX_2 ; |
92 | ||
93 | # If the default value of a feature is used, then the | |
94 | # default value of its subfeatures should also be used. | |
95 | check i : source.input : <expected-define>SF_1 ; | |
96 | ||
97 | # Subfeatures should be expanded when listed in a | |
98 | # target reference. | |
99 | check j-impl : source.input : <expected-define>CF_1 ; | |
100 | explicit j-impl ; | |
101 | alias j : j-impl/<cf>on-1 ; | |
7c673cae FG |
102 | """) |
103 | ||
104 | t.write("jamroot.jam", """ | |
105 | import feature ; | |
11fdf7f2 | 106 | feature.feature cf : off on always : composite incidental ; |
7c673cae FG |
107 | feature.compose <cf>off : <define>CF_IS_OFF ; |
108 | feature.subfeature cf on : version : 1 2 : composite optional incidental ; | |
109 | feature.compose <cf-on:version>1 : <define>CF_1 ; | |
11fdf7f2 TL |
110 | feature.subfeature cf always : version : 1 2 : composite incidental ; |
111 | feature.compose <cf-always:version>1 : <define>CF_2 ; | |
112 | feature.feature fopt : on off : optional incidental ; | |
113 | feature.subfeature fopt : version : 1 2 : composite incidental ; | |
114 | feature.compose <fopt-version>2 : <define>FOPT_2 ; | |
115 | ||
116 | feature.feature cx1 : on : composite incidental ; | |
117 | feature.feature cx2 : on : optional incidental ; | |
118 | feature.subfeature cx2 on : sub : 1 : composite incidental ; | |
119 | feature.compose <cx1>on : <cx2>on ; | |
120 | feature.compose <cx2-on:sub>1 : <define>CX_2 ; | |
7c673cae | 121 | |
92f5a8d4 TL |
122 | feature.feature sf : a : incidental ; |
123 | feature.subfeature sf a : sub : 1 : composite incidental ; | |
124 | feature.compose <sf-a:sub>1 : <define>SF_1 ; | |
7c673cae FG |
125 | """) |
126 | ||
127 | t.expand_toolset("jamfile.jam") | |
7c673cae FG |
128 | |
129 | t.run_build_system() | |
92f5a8d4 TL |
130 | t.expect_addition(["bin/debug/a.check", |
131 | "bin/debug/b.check", | |
132 | "bin/null/release/c.check", | |
133 | "bin/debug/d.check", | |
134 | "bin/debug/e.check", | |
135 | "bin/debug/f.check", | |
136 | "bin/debug/g.check", | |
137 | "bin/debug/h.check", | |
138 | "bin/debug/i.check"]) | |
7c673cae FG |
139 | |
140 | t.cleanup() |