]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/alternatives.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / alternatives.py
CommitLineData
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
10import BoostBuild
11import string
12
13t = BoostBuild.Tester(use_test_config=False)
14
15# Test that basic alternatives selection works.
16t.write("jamroot.jam", "")
17
18t.write("jamfile.jam", """
19exe a : a_empty.cpp ;
20exe a : a.cpp : <variant>release ;
21""")
22
23t.write("a_empty.cpp", "")
24
25t.write("a.cpp", "int main() {}\n")
26
27t.run_build_system(["release"])
28
b32b8144 29t.expect_addition("bin/$toolset/release*/a.exe")
7c673cae
FG
30
31# Test that alternative selection works for ordinary properties, in particular
32# user-defined.
33t.write("jamroot.jam", "")
34
35t.write("jamfile.jam", """
36import feature ;
37feature.feature X : off on : propagated ;
38exe a : b.cpp ;
39exe a : a.cpp : <X>on ;
40""")
41t.write("b.cpp", "int main() {}\n")
42
43t.rm("bin")
44
45t.run_build_system()
b32b8144 46t.expect_addition("bin/$toolset/debug*/b.obj")
7c673cae
FG
47
48t.run_build_system(["X=on"])
b32b8144 49t.expect_addition("bin/$toolset/debug/X-on*/a.obj")
7c673cae
FG
50
51t.rm("bin")
52
53# Test that everything works ok even with the default build.
54t.write("jamfile.jam", """\
55exe a : a_empty.cpp : <variant>release ;
56exe a : a.cpp : <variant>debug ;
57""")
58
59t.run_build_system()
b32b8144 60t.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.
65t.write("jamfile.jam", """\
66exe a : a_empty.cpp : <variant>debug ;
67exe a : a.cpp : <variant>release ;
68""")
69
70t.run_build_system(["release"])
b32b8144 71t.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.
75t.write("jamfile.jam", """
76exe a : a_empty.cpp : <variant>debug <define>FOO <include>BAR ;
77exe a : a.cpp : <variant>release ;
78""")
79
80t.rm("bin/$toolset/release/a.exe")
b32b8144 81t.rm("bin/$toolset/release/*/a.exe")
7c673cae 82t.run_build_system(["release", "define=FOO"])
b32b8144 83t.expect_addition("bin/$toolset/release*/a.exe")
7c673cae
FG
84
85# Test that ambiguity is reported correctly.
86t.write("jamfile.jam", """\
87exe a : a_empty.cpp ;
88exe a : a.cpp ;
89""")
90t.run_build_system(["--no-error-backtrace"], status=None)
91t.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.
95t.write("jamfile.jam", """\
96exe a : a_empty.cpp : <optimization>off <profiling>off ;
97exe a : a.cpp : <debug-symbols>on ;
98""")
99
100t.run_build_system(["--no-error-backtrace"], status=None)
101t.fail_test(string.find(t.stdout(), "No best alternative") == -1)
102
103# Test that we can have alternative without sources.
104t.write("jamfile.jam", """\
105alias specific-sources ;
106import feature ;
107feature.extend os : MAGIC ;
108alias specific-sources : b.cpp : <os>MAGIC ;
109exe a : a.cpp specific-sources ;
110""")
111t.rm("bin")
112t.run_build_system()
113
114t.cleanup()