summaryrefslogtreecommitdiff
path: root/tools/build/test/build_file.py
blob: d670af4284d6db73bfb50fa2ae0fd7a1f6d4b7ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/python

# Copyright (C) 2006. Vladimir Prus
# Copyright (C) 2008. Jurko Gospodnetic
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

# Tests that we explicitly request a file (not target) to be built by
# specifying its name on the command line.

import BoostBuild


###############################################################################
#
# test_building_file_from_specific_project()
# ------------------------------------------
#
###############################################################################

def test_building_file_from_specific_project():
    t = BoostBuild.Tester(use_test_config=False)

    t.write("jamroot.jam", """\
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
build-project sub ;
""")
    t.write("hello.cpp", "int main() {}\n")
    t.write("sub/jamfile.jam", """
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
exe sub : hello.cpp ;
""")
    t.write("sub/hello.cpp", "int main() {}\n")

    t.run_build_system(["sub", t.adjust_suffix("hello.obj")])
    t.expect_output_lines("*depends on itself*", False)
    t.expect_addition("sub/bin/$toolset/debug/hello.obj")
    t.expect_nothing_more()

    t.cleanup()


###############################################################################
#
# test_building_file_from_specific_target()
# -----------------------------------------
#
###############################################################################

def test_building_file_from_specific_target():
    t = BoostBuild.Tester(use_test_config=False)

    t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
    t.write("hello1.cpp", "int main() {}\n")
    t.write("hello2.cpp", "int main() {}\n")
    t.write("hello3.cpp", "int main() {}\n")

    t.run_build_system(["hello1", t.adjust_suffix("hello1.obj")])
    t.expect_addition("bin/$toolset/debug/hello1.obj")
    t.expect_nothing_more()

    t.cleanup()


###############################################################################
#
# test_building_missing_file_from_specific_target()
# -------------------------------------------------
#
###############################################################################

def test_building_missing_file_from_specific_target():
    t = BoostBuild.Tester(use_test_config=False)

    t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
    t.write("hello1.cpp", "int main() {}\n")
    t.write("hello2.cpp", "int main() {}\n")
    t.write("hello3.cpp", "int main() {}\n")

    obj = t.adjust_suffix("hello2.obj")
    t.run_build_system(["hello1", obj], status=1)
    t.expect_output_lines("don't know how to make*" + obj)
    t.expect_nothing_more()

    t.cleanup()


###############################################################################
#
# test_building_multiple_files_with_different_names()
# ---------------------------------------------------
#
###############################################################################

def test_building_multiple_files_with_different_names():
    t = BoostBuild.Tester(use_test_config=False)

    t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
    t.write("hello1.cpp", "int main() {}\n")
    t.write("hello2.cpp", "int main() {}\n")
    t.write("hello3.cpp", "int main() {}\n")

    t.run_build_system([t.adjust_suffix("hello1.obj"), t.adjust_suffix(
        "hello2.obj")])
    t.expect_addition("bin/$toolset/debug/hello1.obj")
    t.expect_addition("bin/$toolset/debug/hello2.obj")
    t.expect_nothing_more()

    t.cleanup()


###############################################################################
#
# test_building_multiple_files_with_the_same_name()
# -------------------------------------------------
#
###############################################################################

def test_building_multiple_files_with_the_same_name():
    t = BoostBuild.Tester(use_test_config=False)

    t.write("jamroot.jam", """\
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
build-project sub ;
""")
    t.write("hello.cpp", "int main() {}\n")
    t.write("sub/jamfile.jam", """
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
exe sub : hello.cpp ;
""")
    t.write("sub/hello.cpp", "int main() {}\n")

    t.run_build_system([t.adjust_suffix("hello.obj")])
    t.expect_output_lines("*depends on itself*", False)
    t.expect_addition("bin/$toolset/debug/hello.obj")
    t.expect_addition("sub/bin/$toolset/debug/hello.obj")
    t.expect_nothing_more()

    t.cleanup()


###############################################################################
#
# main()
# ------
#
###############################################################################

test_building_file_from_specific_project()
test_building_file_from_specific_target()
test_building_missing_file_from_specific_target()
test_building_multiple_files_with_different_names()
test_building_multiple_files_with_the_same_name()