]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/project_glob.py
3 # Copyright (C) 2003. Vladimir Prus
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
8 # Test the 'glob' rule in Jamfile context.
14 t
= BoostBuild
.Tester(use_test_config
=False)
16 t
.write("jamroot.jam", "")
17 t
.write("d1/a.cpp", "int main() {}\n")
18 t
.write("d1/jamfile.jam", "exe a : [ glob *.cpp ] ../d2/d//l ;")
19 t
.write("d2/d/l.cpp", """\
22 void force_import_lib_creation() {}
25 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
26 t
.write("d3/d/jamfile.jam", "exe a : [ glob ../*.cpp ] ;")
27 t
.write("d3/a.cpp", "int main() {}\n")
29 t
.run_build_system(subdir
="d1")
30 t
.expect_addition("d1/bin/$toolset/debug*/a.exe")
32 t
.run_build_system(subdir
="d3/d")
33 t
.expect_addition("d3/d/bin/$toolset/debug*/a.exe")
36 t
.run_build_system(subdir
="d2/d")
37 t
.expect_addition("d2/d/bin/$toolset/debug*/l.dll")
42 def test_source_location():
44 Test that when 'source-location' is explicitly-specified glob works
45 relative to the source location.
48 t
= BoostBuild
.Tester(use_test_config
=False)
50 t
.write("jamroot.jam", "")
51 t
.write("d1/a.cpp", "very bad non-compilable file\n")
52 t
.write("d1/src/a.cpp", "int main() {}\n")
53 t
.write("d1/jamfile.jam", """\
54 project : source-location src ;
55 exe a : [ glob *.cpp ] ../d2/d//l ;
57 t
.write("d2/d/l.cpp", """\
60 void force_import_lib_creation() {}
63 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
65 t
.run_build_system(subdir
="d1")
66 t
.expect_addition("d1/bin/$toolset/debug*/a.exe")
71 def test_wildcards_and_exclusion_patterns():
73 Test that wildcards can include directories. Also test exclusion
77 t
= BoostBuild
.Tester(use_test_config
=False)
79 t
.write("jamroot.jam", "")
80 t
.write("d1/src/foo/a.cpp", "void bar(); int main() { bar(); }\n")
81 t
.write("d1/src/bar/b.cpp", "void bar() {}\n")
82 t
.write("d1/src/bar/bad.cpp", "very bad non-compilable file\n")
83 t
.write("d1/jamfile.jam", """\
84 project : source-location src ;
85 exe a : [ glob foo/*.cpp bar/*.cpp : bar/bad* ] ../d2/d//l ;
87 t
.write("d2/d/l.cpp", """\
90 void force_import_lib_creation() {}
93 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
95 t
.run_build_system(subdir
="d1")
96 t
.expect_addition("d1/bin/$toolset/debug*/a.exe")
101 def test_glob_tree():
102 """Test that 'glob-tree' works."""
104 t
= BoostBuild
.Tester(use_test_config
=False)
106 t
.write("jamroot.jam", "")
107 t
.write("d1/src/foo/a.cpp", "void bar(); int main() { bar(); }\n")
108 t
.write("d1/src/bar/b.cpp", "void bar() {}\n")
109 t
.write("d1/src/bar/bad.cpp", "very bad non-compilable file\n")
110 t
.write("d1/jamfile.jam", """\
111 project : source-location src ;
112 exe a : [ glob-tree *.cpp : bad* ] ../d2/d//l ;
114 t
.write("d2/d/l.cpp", """\
116 __declspec(dllexport)
117 void force_import_lib_creation() {}
120 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
122 t
.run_build_system(subdir
="d1")
123 t
.expect_addition("d1/bin/$toolset/debug*/a.exe")
128 def test_directory_names_in_glob_tree():
129 """Test that directory names in patterns for 'glob-tree' are rejected."""
131 t
= BoostBuild
.Tester(use_test_config
=False)
133 t
.write("jamroot.jam", "")
134 t
.write("d1/src/a.cpp", "very bad non-compilable file\n")
135 t
.write("d1/src/foo/a.cpp", "void bar(); int main() { bar(); }\n")
136 t
.write("d1/src/bar/b.cpp", "void bar() {}\n")
137 t
.write("d1/src/bar/bad.cpp", "very bad non-compilable file\n")
138 t
.write("d1/jamfile.jam", """\
139 project : source-location src ;
140 exe a : [ glob-tree foo/*.cpp bar/*.cpp : bad* ] ../d2/d//l ;
142 t
.write("d2/d/l.cpp", """\
144 __declspec(dllexport)
145 void force_import_lib_creation() {}
148 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
150 t
.run_build_system(subdir
="d1", status
=1)
151 t
.expect_output_lines("error: The patterns * may not include directory")
156 def test_glob_with_absolute_names():
157 """Test that 'glob' works with absolute names."""
159 t
= BoostBuild
.Tester(use_test_config
=False)
161 t
.write("jamroot.jam", "")
162 t
.write("d1/src/a.cpp", "very bad non-compilable file\n")
163 t
.write("d1/src/foo/a.cpp", "void bar(); int main() { bar(); }\n")
164 t
.write("d1/src/bar/b.cpp", "void bar() {}\n")
165 # Note that to get the current dir, we use bjam's PWD, not Python's
166 # os.getcwd(), because the former will always return a long path while the
167 # latter might return a short path, which would confuse path.glob.
168 t
.write("d1/jamfile.jam", """\
169 project : source-location src ;
170 local pwd = [ PWD ] ; # Always absolute.
171 exe a : [ glob $(pwd)/src/foo/*.cpp $(pwd)/src/bar/*.cpp ] ../d2/d//l ;
173 t
.write("d2/d/l.cpp", """\
175 __declspec(dllexport)
176 void force_import_lib_creation() {}
179 t
.write("d2/d/jamfile.jam", "lib l : [ glob *.cpp ] ;")
181 t
.run_build_system(subdir
="d1")
182 t
.expect_addition("d1/bin/$toolset/debug*/a.exe")
187 def test_glob_excludes_in_subdirectory():
189 Regression test: glob excludes used to be broken when building from a
193 t
= BoostBuild
.Tester(use_test_config
=False)
195 t
.write("jamroot.jam", "build-project p ;")
196 t
.write("p/p.c", "int main() {}\n")
197 t
.write("p/p_x.c", "very bad non-compilable file\n")
198 t
.write("p/jamfile.jam", "exe p : [ glob *.c : p_x.c ] ;")
200 t
.run_build_system(subdir
="p")
201 t
.expect_addition("p/bin/$toolset/debug*/p.exe")
207 test_source_location()
208 test_wildcards_and_exclusion_patterns()
210 test_directory_names_in_glob_tree()
211 test_glob_with_absolute_names()
212 test_glob_excludes_in_subdirectory()