]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | # | |
3 | # Copyright (c) 2008 Steven Watanabe | |
4 | # | |
5 | # Distributed under the Boost Software License, Version 1.0. (See | |
1e59de90 TL |
6 | # accompanying file LICENSE.txt) or copy at |
7 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
8 | |
9 | import BoostBuild | |
10 | ||
11 | def test_default_order(): | |
12 | tester = BoostBuild.Tester(use_test_config=False) | |
13 | tester.write("jamroot.jam", """ | |
14 | ||
15 | import order ; | |
16 | import "class" : new ; | |
17 | ||
18 | obj test : test.cpp : <include>b <include>a ; | |
19 | """) | |
20 | ||
21 | tester.write("test.cpp", """ | |
22 | #include <test.hpp> | |
23 | int main() { f(); } | |
24 | """) | |
1e59de90 | 25 | |
7c673cae FG |
26 | tester.write("a/test.hpp", """ |
27 | void f(); | |
28 | """) | |
1e59de90 | 29 | |
7c673cae FG |
30 | tester.write("b/test.hpp", """ |
31 | """) | |
1e59de90 | 32 | |
7c673cae | 33 | tester.run_build_system() |
1e59de90 | 34 | |
b32b8144 | 35 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
1e59de90 | 36 | |
7c673cae FG |
37 | # Check that the dependencies are correct |
38 | tester.touch("a/test.hpp") | |
39 | tester.run_build_system() | |
b32b8144 | 40 | tester.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae | 41 | tester.expect_nothing_more() |
1e59de90 | 42 | |
7c673cae FG |
43 | tester.touch("b/test.hpp") |
44 | tester.run_build_system() | |
45 | tester.expect_nothing_more() | |
46 | ||
47 | tester.cleanup() | |
48 | ||
49 | def test_default_order_mixed(): | |
50 | tester = BoostBuild.Tester(use_test_config=False) | |
51 | tester.write("jamroot.jam", """ | |
52 | ||
53 | import order ; | |
54 | import "class" : new ; | |
55 | ||
56 | obj test : test.cpp : <include>b <include>a <include>c&&d ; | |
57 | """) | |
58 | ||
59 | tester.write("test.cpp", """ | |
60 | #include <test.hpp> | |
61 | int main() { f(); } | |
62 | """) | |
1e59de90 | 63 | |
7c673cae FG |
64 | tester.write("a/test.hpp", """ |
65 | void f(); | |
66 | """) | |
1e59de90 | 67 | |
7c673cae FG |
68 | tester.write("b/test.hpp", """ |
69 | """) | |
1e59de90 | 70 | |
7c673cae | 71 | tester.run_build_system() |
1e59de90 | 72 | |
b32b8144 | 73 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
1e59de90 | 74 | |
7c673cae FG |
75 | # Check that the dependencies are correct |
76 | tester.touch("a/test.hpp") | |
77 | tester.run_build_system() | |
b32b8144 | 78 | tester.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae | 79 | tester.expect_nothing_more() |
1e59de90 | 80 | |
7c673cae FG |
81 | tester.touch("b/test.hpp") |
82 | tester.run_build_system() | |
83 | tester.expect_nothing_more() | |
84 | ||
85 | tester.cleanup() | |
86 | ||
87 | def test_basic(): | |
88 | tester = BoostBuild.Tester(use_test_config=False) | |
89 | tester.write("jamroot.jam", """ | |
90 | obj test : test.cpp : <include>a&&b ; | |
91 | """) | |
92 | ||
93 | tester.write("test.cpp", """ | |
94 | #include <test1.hpp> | |
95 | #include <test2.hpp> | |
96 | int main() {} | |
97 | """) | |
98 | ||
99 | tester.write("a/test1.hpp", """ | |
100 | """) | |
101 | ||
102 | tester.write("b/test2.hpp", """ | |
103 | """) | |
104 | ||
105 | tester.run_build_system() | |
106 | ||
b32b8144 | 107 | tester.expect_addition("bin/$toolset/debug*/test.obj") |
7c673cae FG |
108 | |
109 | # Check that the dependencies are correct | |
110 | tester.touch("a/test1.hpp") | |
111 | tester.run_build_system() | |
b32b8144 | 112 | tester.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
113 | |
114 | tester.touch("b/test2.hpp") | |
115 | tester.run_build_system() | |
b32b8144 | 116 | tester.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
117 | |
118 | tester.cleanup() | |
119 | ||
120 | def test_order1(): | |
121 | t = BoostBuild.Tester(use_test_config=False) | |
122 | t.write("jamroot.jam", """ | |
123 | obj test : test.cpp : <include>a&&b ; | |
124 | """) | |
125 | t.write("test.cpp", """ | |
126 | #include <test.h> | |
127 | int main() {} | |
128 | """) | |
129 | t.write("a/test.h", """ | |
130 | """) | |
131 | t.write("b/test.h", """ | |
132 | #error should find a/test.h | |
133 | """) | |
134 | t.run_build_system() | |
135 | ||
136 | t.touch("a/test.h") | |
137 | t.run_build_system() | |
b32b8144 | 138 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
139 | t.expect_nothing_more() |
140 | ||
141 | t.touch("b/test.h") | |
142 | t.run_build_system() | |
143 | t.expect_nothing_more() | |
144 | ||
145 | t.cleanup() | |
146 | ||
147 | def test_order2(): | |
148 | t = BoostBuild.Tester(use_test_config=False) | |
149 | t.write("jamroot.jam", """ | |
150 | obj test : test.cpp : <include>b&&a ; | |
151 | """) | |
152 | t.write("test.cpp", """ | |
153 | #include <test.h> | |
154 | int main() {} | |
155 | """) | |
156 | t.write("a/test.h", """ | |
157 | #error should find b/test.h | |
158 | """) | |
159 | t.write("b/test.h", """ | |
160 | """) | |
161 | t.run_build_system() | |
162 | ||
163 | t.touch("a/test.h") | |
164 | t.run_build_system() | |
165 | t.expect_nothing_more() | |
166 | ||
167 | t.touch("b/test.h") | |
168 | t.run_build_system() | |
b32b8144 | 169 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
170 | t.expect_nothing_more() |
171 | ||
172 | t.cleanup() | |
173 | ||
174 | def test_order_graph(): | |
175 | t = BoostBuild.Tester(use_test_config=False) | |
176 | t.write("jamroot.jam", """ | |
177 | obj test : test.cpp : | |
178 | <include>b&&a | |
179 | <include>c&&b | |
180 | <include>a | |
181 | <include>c | |
182 | <include>b | |
183 | <include>e&&b&&d | |
184 | ; | |
185 | """) | |
186 | t.write("test.cpp", """ | |
187 | #include <test1.h> | |
188 | #include <test2.h> | |
189 | #include <test3.h> | |
190 | #include <test4.h> | |
191 | int main() {} | |
192 | """) | |
193 | t.write("b/test1.h", "") | |
194 | t.write("a/test1.h", "#error should find b/test1.h\n") | |
195 | ||
196 | t.write("c/test2.h", "") | |
197 | t.write("b/test2.h", "#error should find c/test2.h\n") | |
198 | ||
199 | t.write("e/test3.h", "") | |
200 | t.write("b/test3.h", "#error should find e/test3.h\n") | |
201 | ||
202 | t.write("b/test4.h", "") | |
203 | t.write("d/test4.h", "#error should find b/test4.h\n") | |
204 | ||
205 | t.run_build_system() | |
b32b8144 | 206 | t.expect_addition("bin/$toolset/debug*/test.obj") |
7c673cae FG |
207 | |
208 | t.touch("b/test1.h") | |
209 | t.run_build_system() | |
b32b8144 | 210 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
211 | t.expect_nothing_more() |
212 | ||
213 | t.touch("a/test1.h") | |
214 | t.run_build_system() | |
215 | t.expect_nothing_more() | |
216 | ||
217 | t.touch("c/test2.h") | |
218 | t.run_build_system() | |
b32b8144 | 219 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
220 | t.expect_nothing_more() |
221 | ||
222 | t.touch("b/test2.h") | |
223 | t.run_build_system() | |
224 | t.expect_nothing_more() | |
225 | ||
226 | t.touch("e/test3.h") | |
227 | t.run_build_system() | |
b32b8144 | 228 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
229 | t.expect_nothing_more() |
230 | ||
231 | t.touch("b/test3.h") | |
232 | t.run_build_system() | |
233 | t.expect_nothing_more() | |
234 | ||
235 | t.touch("b/test4.h") | |
236 | t.run_build_system() | |
b32b8144 | 237 | t.expect_touch("bin/$toolset/debug*/test.obj") |
7c673cae FG |
238 | t.expect_nothing_more() |
239 | ||
240 | t.touch("d/test4.h") | |
241 | t.run_build_system() | |
242 | t.expect_nothing_more() | |
243 | ||
244 | t.cleanup() | |
245 | ||
246 | test_default_order() | |
247 | test_default_order_mixed() | |
248 | test_basic() | |
249 | test_order1() | |
250 | test_order2() | |
251 | test_order_graph() |