-
Notifications
You must be signed in to change notification settings - Fork 13.3k
/
Copy pathcompute_projects_test.py
210 lines (190 loc) · 8.23 KB
/
compute_projects_test.py
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Does some stuff."""
import unittest
import compute_projects
class TestComputeProjects(unittest.TestCase):
def test_llvm(self):
env_variables = compute_projects.get_env_variables(
["llvm/CMakeLists.txt"], "Linux"
)
self.assertEqual(
env_variables["projects_to_build"],
"bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
def test_llvm_windows(self):
env_variables = compute_projects.get_env_variables(
["llvm/CMakeLists.txt"], "Windows"
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;lld;llvm;mlir;polly",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-tools check-lld check-llvm check-mlir check-polly",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
def test_llvm_mac(self):
env_variables = compute_projects.get_env_variables(
["llvm/CMakeLists.txt"], "Darwin"
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;lld;llvm;mlir",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-tools check-lld check-llvm check-mlir",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
def test_clang(self):
env_variables = compute_projects.get_env_variables(
["clang/CMakeLists.txt"], "Linux"
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;compiler-rt;lld;llvm",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-tools check-compiler-rt",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
def test_clang_windows(self):
env_variables = compute_projects.get_env_variables(
["clang/CMakeLists.txt"], "Windows"
)
self.assertEqual(
env_variables["projects_to_build"], "clang;clang-tools-extra;llvm"
)
self.assertEqual(
env_variables["project_check_targets"], "check-clang check-clang-tools"
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
def test_bolt(self):
env_variables = compute_projects.get_env_variables(
["bolt/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "bolt;clang;lld;llvm")
self.assertEqual(env_variables["project_check_targets"], "check-bolt")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_lldb(self):
env_variables = compute_projects.get_env_variables(
["lldb/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "clang;lldb;llvm")
self.assertEqual(env_variables["project_check_targets"], "check-lldb")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_mlir(self):
env_variables = compute_projects.get_env_variables(
["mlir/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "clang;flang;llvm;mlir")
self.assertEqual(
env_variables["project_check_targets"], "check-flang check-mlir"
)
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_flang(self):
env_variables = compute_projects.get_env_variables(
["flang/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "clang;flang;llvm")
self.assertEqual(env_variables["project_check_targets"], "check-flang")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_invalid_subproject(self):
env_variables = compute_projects.get_env_variables(
[".ci/compute_projects.py"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_top_level_file(self):
env_variables = compute_projects.get_env_variables(["README.md"], "Linux")
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_exclude_runtiems_in_projects(self):
env_variables = compute_projects.get_env_variables(
[".ci/compute_projects.py", "libcxx/CMakeLists.txt"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_exclude_docs(self):
env_variables = compute_projects.get_env_variables(
["llvm/docs/CIBestPractices.rst"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_exclude_gn(self):
env_variables = compute_projects.get_env_variables(
["llvm/utils/gn/build/BUILD.gn"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "")
self.assertEqual(env_variables["project_check_targets"], "")
self.assertEqual(env_variables["runtimes_to_build"], "")
self.assertEqual(env_variables["runtimes_check_targets"], "")
def test_ci(self):
env_variables = compute_projects.get_env_variables(
[".ci/compute_projects.py"], "Linux"
)
self.assertEqual(env_variables["projects_to_build"], "clang;lld;llvm;lldb")
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-lld check-llvm check-lldb",
)
self.assertEqual(
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
)
self.assertEqual(
env_variables["runtimes_check_targets"],
"check-cxx check-cxxabi check-unwind",
)
if __name__ == "__main__":
unittest.main()