]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/clean.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / test / clean.py
1 #!/usr/bin/python
2
3 # Copyright (C) Vladimir Prus 2006.
4 # Distributed under the Boost Software License, Version 1.0. (See
5 # accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 import BoostBuild
9
10 t = BoostBuild.Tester(use_test_config=False)
11
12 t.write("a.cpp", "int main() {}\n")
13 t.write("jamroot.jam", "exe a : a.cpp sub1//sub1 sub2//sub2 sub3//sub3 ;")
14 t.write("sub1/jamfile.jam", """\
15 lib sub1 : sub1.cpp sub1_2 ../sub2//sub2 ;
16 lib sub1_2 : sub1_2.cpp ;
17 """)
18
19 t.write("sub1/sub1.cpp", """\
20 #ifdef _WIN32
21 __declspec(dllexport)
22 #endif
23 void sub1() {}
24 """)
25
26 t.write("sub1/sub1_2.cpp", """\
27 #ifdef _WIN32
28 __declspec(dllexport)
29 #endif
30 void sub1() {}
31 """)
32
33 t.write("sub2/jamfile.jam", "lib sub2 : sub2.cpp ;")
34 t.write("sub2/sub2.cpp", """\
35 #ifdef _WIN32
36 __declspec(dllexport)
37 #endif
38 void sub2() {}
39 """)
40
41 t.write("sub3/jamroot.jam", "lib sub3 : sub3.cpp ;")
42 t.write("sub3/sub3.cpp", """\
43 #ifdef _WIN32
44 __declspec(dllexport)
45 #endif
46 void sub3() {}
47 """)
48
49 # 'clean' should not remove files under separate jamroot.jam.
50 t.run_build_system()
51 t.run_build_system(["--clean"])
52 t.expect_removal("bin/$toolset/debug/a.obj")
53 t.expect_removal("sub1/bin/$toolset/debug/sub1.obj")
54 t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
55 t.expect_removal("sub2/bin/$toolset/debug/sub2.obj")
56 t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
57
58 # 'clean-all' removes everything it can reach.
59 t.run_build_system()
60 t.run_build_system(["--clean-all"])
61 t.expect_removal("bin/$toolset/debug/a.obj")
62 t.expect_removal("sub1/bin/$toolset/debug/sub1.obj")
63 t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
64 t.expect_removal("sub2/bin/$toolset/debug/sub2.obj")
65 t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
66
67 # 'clean' together with project target removes only under that project.
68 t.run_build_system()
69 t.run_build_system(["sub1", "--clean"])
70 t.expect_nothing("bin/$toolset/debug/a.obj")
71 t.expect_removal("sub1/bin/$toolset/debug/sub1.obj")
72 t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
73 t.expect_nothing("sub2/bin/$toolset/debug/sub2.obj")
74 t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
75
76 # 'clean-all' removes everything.
77 t.run_build_system()
78 t.run_build_system(["sub1", "--clean-all"])
79 t.expect_nothing("bin/$toolset/debug/a.obj")
80 t.expect_removal("sub1/bin/$toolset/debug/sub1.obj")
81 t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
82 t.expect_removal("sub2/bin/$toolset/debug/sub2.obj")
83 t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
84
85 # If main target is explicitly named, we should not remove files from other
86 # targets.
87 t.run_build_system()
88 t.run_build_system(["sub1//sub1", "--clean"])
89 t.expect_removal("sub1/bin/$toolset/debug/sub1.obj")
90 t.expect_nothing("sub1/bin/$toolset/debug/sub1_2.obj")
91 t.expect_nothing("sub2/bin/$toolset/debug/sub2.obj")
92 t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
93
94 # Regression test: sources of the 'cast' rule were mistakenly deleted.
95 t.rm(".")
96 t.write("jamroot.jam", """\
97 import cast ;
98 cast a cpp : a.h ;
99 """)
100 t.write("a.h", "")
101 t.run_build_system(["--clean"])
102 t.expect_nothing("a.h")
103
104 t.cleanup()