]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2003 Dave Abrahams | |
4 | # Copyright 2003, 2006 Vladimir Prus | |
5 | # Distributed under the Boost Software License, Version 1.0. | |
6 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | # Test main target alternatives. | |
9 | ||
10 | import BoostBuild | |
11 | import string | |
12 | ||
13 | t = BoostBuild.Tester(use_test_config=False) | |
14 | ||
15 | # Test that basic alternatives selection works. | |
16 | t.write("jamroot.jam", "") | |
17 | ||
18 | t.write("jamfile.jam", """ | |
19 | exe a : a_empty.cpp ; | |
20 | exe a : a.cpp : <variant>release ; | |
21 | """) | |
22 | ||
23 | t.write("a_empty.cpp", "") | |
24 | ||
25 | t.write("a.cpp", "int main() {}\n") | |
26 | ||
27 | t.run_build_system(["release"]) | |
28 | ||
b32b8144 | 29 | t.expect_addition("bin/$toolset/release*/a.exe") |
7c673cae FG |
30 | |
31 | # Test that alternative selection works for ordinary properties, in particular | |
32 | # user-defined. | |
33 | t.write("jamroot.jam", "") | |
34 | ||
35 | t.write("jamfile.jam", """ | |
36 | import feature ; | |
37 | feature.feature X : off on : propagated ; | |
38 | exe a : b.cpp ; | |
39 | exe a : a.cpp : <X>on ; | |
40 | """) | |
41 | t.write("b.cpp", "int main() {}\n") | |
42 | ||
43 | t.rm("bin") | |
44 | ||
45 | t.run_build_system() | |
b32b8144 | 46 | t.expect_addition("bin/$toolset/debug*/b.obj") |
7c673cae FG |
47 | |
48 | t.run_build_system(["X=on"]) | |
b32b8144 | 49 | t.expect_addition("bin/$toolset/debug/X-on*/a.obj") |
7c673cae FG |
50 | |
51 | t.rm("bin") | |
52 | ||
53 | # Test that everything works ok even with the default build. | |
54 | t.write("jamfile.jam", """\ | |
55 | exe a : a_empty.cpp : <variant>release ; | |
56 | exe a : a.cpp : <variant>debug ; | |
57 | """) | |
58 | ||
59 | t.run_build_system() | |
b32b8144 | 60 | t.expect_addition("bin/$toolset/debug*/a.exe") |
7c673cae FG |
61 | |
62 | # Test that only properties which are in the build request matter for | |
63 | # alternative selection. IOW, alternative with <variant>release is better than | |
64 | # one with <variant>debug when building the release variant. | |
65 | t.write("jamfile.jam", """\ | |
66 | exe a : a_empty.cpp : <variant>debug ; | |
67 | exe a : a.cpp : <variant>release ; | |
68 | """) | |
69 | ||
70 | t.run_build_system(["release"]) | |
b32b8144 | 71 | t.expect_addition("bin/$toolset/release*/a.exe") |
7c673cae FG |
72 | |
73 | # Test that free properties do not matter. We really do not want <cxxflags> | |
74 | # property in build request to affect alternative selection. | |
75 | t.write("jamfile.jam", """ | |
76 | exe a : a_empty.cpp : <variant>debug <define>FOO <include>BAR ; | |
77 | exe a : a.cpp : <variant>release ; | |
78 | """) | |
79 | ||
80 | t.rm("bin/$toolset/release/a.exe") | |
b32b8144 | 81 | t.rm("bin/$toolset/release/*/a.exe") |
7c673cae | 82 | t.run_build_system(["release", "define=FOO"]) |
b32b8144 | 83 | t.expect_addition("bin/$toolset/release*/a.exe") |
7c673cae FG |
84 | |
85 | # Test that ambiguity is reported correctly. | |
86 | t.write("jamfile.jam", """\ | |
87 | exe a : a_empty.cpp ; | |
88 | exe a : a.cpp ; | |
89 | """) | |
90 | t.run_build_system(["--no-error-backtrace"], status=None) | |
91 | t.fail_test(string.find(t.stdout(), "No best alternative") == -1) | |
92 | ||
93 | # Another ambiguity test: two matches properties in one alternative are neither | |
94 | # better nor worse than a single one in another alternative. | |
95 | t.write("jamfile.jam", """\ | |
96 | exe a : a_empty.cpp : <optimization>off <profiling>off ; | |
97 | exe a : a.cpp : <debug-symbols>on ; | |
98 | """) | |
99 | ||
100 | t.run_build_system(["--no-error-backtrace"], status=None) | |
101 | t.fail_test(string.find(t.stdout(), "No best alternative") == -1) | |
102 | ||
103 | # Test that we can have alternative without sources. | |
104 | t.write("jamfile.jam", """\ | |
105 | alias specific-sources ; | |
106 | import feature ; | |
107 | feature.extend os : MAGIC ; | |
108 | alias specific-sources : b.cpp : <os>MAGIC ; | |
109 | exe a : a.cpp specific-sources ; | |
110 | """) | |
111 | t.rm("bin") | |
112 | t.run_build_system() | |
113 | ||
114 | t.cleanup() |