Aiden Grossman | 9224165 | 2025-03-26 12:37:16 -0700 | [diff] [blame] | 1 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 2 | # See https://llvm.org/LICENSE.txt for license information. |
| 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | """Does some stuff.""" |
| 5 | |
| 6 | import unittest |
| 7 | |
| 8 | import compute_projects |
| 9 | |
| 10 | |
| 11 | class TestComputeProjects(unittest.TestCase): |
| 12 | def test_llvm(self): |
| 13 | env_variables = compute_projects.get_env_variables( |
| 14 | ["llvm/CMakeLists.txt"], "Linux" |
| 15 | ) |
| 16 | self.assertEqual( |
| 17 | env_variables["projects_to_build"], |
| 18 | "bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly", |
| 19 | ) |
| 20 | self.assertEqual( |
| 21 | env_variables["project_check_targets"], |
| 22 | "check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly", |
| 23 | ) |
| 24 | self.assertEqual( |
| 25 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 26 | ) |
| 27 | self.assertEqual( |
| 28 | env_variables["runtimes_check_targets"], |
| 29 | "check-cxx check-cxxabi check-unwind", |
| 30 | ) |
| 31 | |
| 32 | def test_llvm_windows(self): |
| 33 | env_variables = compute_projects.get_env_variables( |
| 34 | ["llvm/CMakeLists.txt"], "Windows" |
| 35 | ) |
| 36 | self.assertEqual( |
| 37 | env_variables["projects_to_build"], |
| 38 | "clang;clang-tools-extra;lld;llvm;mlir;polly", |
| 39 | ) |
| 40 | self.assertEqual( |
| 41 | env_variables["project_check_targets"], |
| 42 | "check-clang check-clang-tools check-lld check-llvm check-mlir check-polly", |
| 43 | ) |
| 44 | self.assertEqual( |
| 45 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 46 | ) |
| 47 | self.assertEqual( |
| 48 | env_variables["runtimes_check_targets"], |
| 49 | "check-cxx check-cxxabi check-unwind", |
| 50 | ) |
| 51 | |
| 52 | def test_llvm_mac(self): |
| 53 | env_variables = compute_projects.get_env_variables( |
| 54 | ["llvm/CMakeLists.txt"], "Darwin" |
| 55 | ) |
| 56 | self.assertEqual( |
| 57 | env_variables["projects_to_build"], |
| 58 | "clang;clang-tools-extra;lld;llvm;mlir", |
| 59 | ) |
| 60 | self.assertEqual( |
| 61 | env_variables["project_check_targets"], |
| 62 | "check-clang check-clang-tools check-lld check-llvm check-mlir", |
| 63 | ) |
| 64 | self.assertEqual( |
| 65 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 66 | ) |
| 67 | self.assertEqual( |
| 68 | env_variables["runtimes_check_targets"], |
| 69 | "check-cxx check-cxxabi check-unwind", |
| 70 | ) |
| 71 | |
| 72 | def test_clang(self): |
| 73 | env_variables = compute_projects.get_env_variables( |
| 74 | ["clang/CMakeLists.txt"], "Linux" |
| 75 | ) |
| 76 | self.assertEqual( |
| 77 | env_variables["projects_to_build"], |
| 78 | "clang;clang-tools-extra;compiler-rt;lld;llvm", |
| 79 | ) |
| 80 | self.assertEqual( |
| 81 | env_variables["project_check_targets"], |
| 82 | "check-clang check-clang-tools check-compiler-rt", |
| 83 | ) |
| 84 | self.assertEqual( |
| 85 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 86 | ) |
| 87 | self.assertEqual( |
| 88 | env_variables["runtimes_check_targets"], |
| 89 | "check-cxx check-cxxabi check-unwind", |
| 90 | ) |
| 91 | |
| 92 | def test_clang_windows(self): |
| 93 | env_variables = compute_projects.get_env_variables( |
| 94 | ["clang/CMakeLists.txt"], "Windows" |
| 95 | ) |
| 96 | self.assertEqual( |
| 97 | env_variables["projects_to_build"], "clang;clang-tools-extra;llvm" |
| 98 | ) |
| 99 | self.assertEqual( |
| 100 | env_variables["project_check_targets"], "check-clang check-clang-tools" |
| 101 | ) |
| 102 | self.assertEqual( |
| 103 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 104 | ) |
| 105 | self.assertEqual( |
| 106 | env_variables["runtimes_check_targets"], |
| 107 | "check-cxx check-cxxabi check-unwind", |
| 108 | ) |
| 109 | |
| 110 | def test_bolt(self): |
| 111 | env_variables = compute_projects.get_env_variables( |
| 112 | ["bolt/CMakeLists.txt"], "Linux" |
| 113 | ) |
| 114 | self.assertEqual(env_variables["projects_to_build"], "bolt;clang;lld;llvm") |
| 115 | self.assertEqual(env_variables["project_check_targets"], "check-bolt") |
| 116 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 117 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 118 | |
| 119 | def test_lldb(self): |
| 120 | env_variables = compute_projects.get_env_variables( |
| 121 | ["lldb/CMakeLists.txt"], "Linux" |
| 122 | ) |
| 123 | self.assertEqual(env_variables["projects_to_build"], "clang;lldb;llvm") |
| 124 | self.assertEqual(env_variables["project_check_targets"], "check-lldb") |
| 125 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 126 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 127 | |
| 128 | def test_mlir(self): |
| 129 | env_variables = compute_projects.get_env_variables( |
| 130 | ["mlir/CMakeLists.txt"], "Linux" |
| 131 | ) |
| 132 | self.assertEqual(env_variables["projects_to_build"], "clang;flang;llvm;mlir") |
| 133 | self.assertEqual( |
| 134 | env_variables["project_check_targets"], "check-flang check-mlir" |
| 135 | ) |
| 136 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 137 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 138 | |
| 139 | def test_flang(self): |
| 140 | env_variables = compute_projects.get_env_variables( |
| 141 | ["flang/CMakeLists.txt"], "Linux" |
| 142 | ) |
| 143 | self.assertEqual(env_variables["projects_to_build"], "clang;flang;llvm") |
| 144 | self.assertEqual(env_variables["project_check_targets"], "check-flang") |
| 145 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 146 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 147 | |
| 148 | def test_invalid_subproject(self): |
| 149 | env_variables = compute_projects.get_env_variables( |
| 150 | [".ci/compute_projects.py"], "Linux" |
| 151 | ) |
| 152 | self.assertEqual(env_variables["projects_to_build"], "") |
| 153 | self.assertEqual(env_variables["project_check_targets"], "") |
| 154 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 155 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 156 | |
| 157 | def test_top_level_file(self): |
| 158 | env_variables = compute_projects.get_env_variables(["README.md"], "Linux") |
| 159 | self.assertEqual(env_variables["projects_to_build"], "") |
| 160 | self.assertEqual(env_variables["project_check_targets"], "") |
| 161 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 162 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 163 | |
Aiden Grossman | 2ca27e7 | 2025-03-27 01:51:13 +0000 | [diff] [blame] | 164 | def test_exclude_runtiems_in_projects(self): |
Aiden Grossman | 7da71a6 | 2025-03-26 23:58:40 +0000 | [diff] [blame] | 165 | env_variables = compute_projects.get_env_variables( |
| 166 | [".ci/compute_projects.py", "libcxx/CMakeLists.txt"], "Linux" |
| 167 | ) |
| 168 | self.assertEqual(env_variables["projects_to_build"], "") |
| 169 | self.assertEqual(env_variables["project_check_targets"], "") |
| 170 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 171 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 172 | |
Aiden Grossman | 21eeca3 | 2025-03-28 22:30:41 -0700 | [diff] [blame] | 173 | def test_exclude_docs(self): |
| 174 | env_variables = compute_projects.get_env_variables( |
| 175 | ["llvm/docs/CIBestPractices.rst"], "Linux" |
| 176 | ) |
| 177 | self.assertEqual(env_variables["projects_to_build"], "") |
| 178 | self.assertEqual(env_variables["project_check_targets"], "") |
| 179 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 180 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 181 | |
Aiden Grossman | ce296f1 | 2025-04-01 12:58:16 -0700 | [diff] [blame] | 182 | def test_exclude_gn(self): |
| 183 | env_variables = compute_projects.get_env_variables( |
| 184 | ["llvm/utils/gn/build/BUILD.gn"], "Linux" |
| 185 | ) |
| 186 | self.assertEqual(env_variables["projects_to_build"], "") |
| 187 | self.assertEqual(env_variables["project_check_targets"], "") |
| 188 | self.assertEqual(env_variables["runtimes_to_build"], "") |
| 189 | self.assertEqual(env_variables["runtimes_check_targets"], "") |
| 190 | |
Matheus Izvekov | 30747cf | 2025-04-18 17:42:29 -0300 | [diff] [blame] | 191 | def test_ci(self): |
| 192 | env_variables = compute_projects.get_env_variables( |
| 193 | [".ci/compute_projects.py"], "Linux" |
| 194 | ) |
| 195 | self.assertEqual(env_variables["projects_to_build"], "clang;lld;llvm;lldb") |
| 196 | self.assertEqual( |
| 197 | env_variables["project_check_targets"], |
| 198 | "check-clang check-lld check-llvm check-lldb", |
| 199 | ) |
| 200 | self.assertEqual( |
| 201 | env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind" |
| 202 | ) |
| 203 | self.assertEqual( |
| 204 | env_variables["runtimes_check_targets"], |
| 205 | "check-cxx check-cxxabi check-unwind", |
| 206 | ) |
| 207 | |
Aiden Grossman | 9224165 | 2025-03-26 12:37:16 -0700 | [diff] [blame] | 208 | |
| 209 | if __name__ == "__main__": |
| 210 | unittest.main() |