Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/test/project_glob.py @ 32

Last change on this file since 32 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.1 KB
Line 
1#!/usr/bin/python
2
3# Copyright (C) Vladimir Prus 2003.
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)
7
8#  Test the 'glob' rule in Jamfile context.
9from BoostBuild import Tester, List
10import os
11import string
12
13# Create a temporary working directory
14t = Tester()
15
16t.write("project-root.jam", """
17""")
18
19t.write("Jamfile", """
20""")
21
22t.write("d1/a.cpp", """
23int main() { return 0; }
24
25""")
26
27t.write("d1/Jamfile", """
28exe a : [ glob *.cpp ] ../d2/d//l ;
29""")
30
31t.write("d2/d/l.cpp", """
32#if defined(_WIN32)
33__declspec(dllexport)
34void force_import_lib_creation() {}
35#endif
36""")
37
38t.write("d2/d/Jamfile", """
39lib l : [ glob *.cpp ] ;
40""")
41
42t.write("d3/d/Jamfile", """
43exe a : [ glob ../*.cpp ] ;
44""")
45t.write("d3/a.cpp", """
46int main()
47{
48    return 0;
49}
50""")
51
52t.run_build_system(subdir="d1")
53t.expect_addition("d1/bin/$toolset/debug/a.exe")
54
55t.run_build_system(subdir="d3/d")
56t.expect_addition("d3/d/bin/$toolset/debug/a.exe")
57
58t.rm("d2/d/bin")
59t.run_build_system(subdir="d2/d")
60t.expect_addition("d2/d/bin/$toolset/debug/l.dll")
61
62# Test that when 'source-location' is explicitly-specified
63# glob works relatively to source location
64t.rm("d1")
65
66t.write("d1/src/a.cpp", """
67int main() { return 0; }
68
69""")
70
71t.write("d1/Jamfile", """
72project : source-location src ;
73exe a : [ glob *.cpp ] ../d2/d//l ;
74""")
75
76t.run_build_system(subdir="d1")
77t.expect_addition("d1/bin/$toolset/debug/a.exe")
78
79# Test that wildcards can include directories. Also
80# test exclusion patterns.
81t.rm("d1")
82
83t.write("d1/src/foo/a.cpp", """
84void bar();
85int main() { bar(); return 0; }
86
87""")
88
89t.write("d1/src/bar/b.cpp", """
90void bar() {}
91
92""")
93
94t.write("d1/src/bar/bad.cpp", """
95very bad non-compilable file
96""")
97
98
99t.write("d1/Jamfile", """
100project : source-location src ;
101exe a : [ glob foo/*.cpp bar/*.cpp : bar/bad* ] ../d2/d//l ;
102""")
103
104t.run_build_system(subdir="d1")
105t.expect_addition("d1/bin/$toolset/debug/a.exe")
106
107
108# Test that 'glob-tree' works.
109t.rm("d1/bin/$toolset/debug/a.exe")
110t.write("d1/Jamfile", """
111project : source-location src ;
112exe a : [ glob-tree *.cpp : bad* ] ../d2/d//l ;
113""")
114t.run_build_system(subdir="d1")
115t.expect_addition("d1/bin/$toolset/debug/a.exe")
116
117# Test that directory names in patterns for
118# 'glob-tree' are rejected.
119t.write("d1/Jamfile", """
120project : source-location src ;
121exe a : [ glob-tree foo/*.cpp bar/*.cpp : bad* ] ../d2/d//l ;
122""")
123
124t.run_build_system(subdir="d1", status=1)
125t.expect_output_line("error: The patterns * may not include directory")
126
127
128t.rm("d1/src/bar/bad.cpp")
129
130# Test that 'glob' works with absolute names
131t.rm("d1/bin")
132
133# Note that to get current dir, we use bjam's PWD,
134# not Python's os.getcwd, because the former will
135# always return long path. The latter might return
136# short path, and that will confuse path.glob.
137t.write("d1/Jamfile", """
138project : source-location src ;
139local pwd = [ PWD ] ; # Always absolute
140exe a : [ glob $(pwd)/src/foo/*.cpp $(pwd)/src/bar/*.cpp ] ../d2/d//l ;
141""")
142
143t.run_build_system(subdir="d1")
144t.expect_addition("d1/bin/$toolset/debug/a.exe")
145
146
147t.cleanup()
Note: See TracBrowser for help on using the repository browser.