Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 1 | """Command line interface tests for llvmprojs.py |
| 2 | |
| 3 | Note that although this uses the unittest framework, it does *not* contain unit |
| 4 | tests. |
| 5 | |
| 6 | """ |
| 7 | |
| 8 | import shutil |
| 9 | import os |
| 10 | import subprocess |
| 11 | import unittest |
| 12 | |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 13 | from tempfile import mkdtemp |
| 14 | from uuid import uuid4 |
| 15 | |
| 16 | from linaropy.cd import cd |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 17 | from llvmtestcase import LLVMTestCase |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 18 | |
| 19 | |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 20 | class Testllvmprojs(LLVMTestCase): |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 21 | |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 22 | @classmethod |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 23 | def llvm_projects(cls, *args, **kwargs): |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 24 | return cls.command_with_defaults("projects", *args, **kwargs) |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 25 | |
| 26 | @classmethod |
Diana Picus | efc7bda | 2017-06-09 19:14:08 +0200 | [diff] [blame] | 27 | def get_subproj_repo(cls, subproj): |
| 28 | return os.path.join(cls.repos, subproj) |
| 29 | |
| 30 | @classmethod |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 31 | def setUpClass(cls): |
| 32 | """Create the file structure and environment that llvmprojs expects""" |
| 33 | cls.llvm_root = mkdtemp() |
| 34 | cls.repos = os.path.join(cls.llvm_root, "repos") |
| 35 | |
| 36 | cls.all_repos = ("llvm", "clang", "compiler-rt", "lld", "lldb", |
| 37 | "libcxx", "libcxxabi", "libunwind", "test-suite") |
| 38 | |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 39 | # Create dummy repos |
| 40 | for reponame in cls.all_repos: |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 41 | cls.create_dummy_repo(cls.get_subproj_repo(reponame)) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 42 | |
| 43 | @classmethod |
| 44 | def tearDownClass(cls): |
| 45 | shutil.rmtree(cls.llvm_root) |
| 46 | |
| 47 | @classmethod |
| 48 | def setUp(cls): |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 49 | cls.env = os.path.join(cls.llvm_root, "env" + str(uuid4())) |
| 50 | cls.llvm_src = os.path.join(cls.env, "llvm") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 51 | |
| 52 | # Create LLVM worktree |
| 53 | cls.branch = "br" + str(uuid4()) |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 54 | cls.add_worktree(cls.get_subproj_repo("llvm"), cls.llvm_src, |
| 55 | cls.branch) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 56 | |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 57 | @classmethod |
| 58 | def tearDown(cls): |
| 59 | # Clean up the directories where we might have added subprojects. |
| 60 | # This isn't 100% clean, because we don't clean up the repos between |
| 61 | # tests (so any branches will remain), but it's good enough for the |
| 62 | # current tests. |
| 63 | for subprojdir in (os.path.join(cls.llvm_src, "projects"), |
| 64 | os.path.join(cls.llvm_src, "tools")): |
| 65 | if os.path.isdir(subprojdir): |
| 66 | shutil.rmtree(subprojdir) |
| 67 | os.makedirs(subprojdir) |
| 68 | |
| 69 | # Run prune on the original repos, to remove any dangling worktrees. |
| 70 | for reponame in cls.all_repos: |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 71 | repopath = cls.get_subproj_repo(reponame) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 72 | with cd(repopath): |
| 73 | cls.run_quietly(["git", "worktree", "prune"]) |
| 74 | |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 75 | def test_repos_arg_is_compulsory_for_add(self): |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 76 | """ |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 77 | Test that we must pass in the repos when adding a subproject, but not |
| 78 | for other combinations of arguments. |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 79 | """ |
| 80 | with self.assertRaises(subprocess.CalledProcessError) as context: |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 81 | self.run_with_output( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 82 | self.llvm_projects("--add", "clang")) |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 83 | |
| 84 | self.assertRegex( |
| 85 | str(context.exception.output), |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 86 | "(.*\n)*.*When adding a subproject you must also pass the --repos argument(.*\n)*") |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 87 | |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 88 | # These should not raise. |
| 89 | self.run_with_output(self.llvm_projects()) |
| 90 | self.run_with_output( |
| 91 | self.llvm_projects("--remove", "clang")) |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 92 | |
| 93 | def test_env_arg_is_compulsory(self): |
| 94 | """ |
| 95 | Test that we must pass in the environment for various combinations of |
| 96 | input args. |
| 97 | """ |
| 98 | with self.assertRaises(subprocess.CalledProcessError) as context: |
| 99 | self.run_with_output(self.llvm_projects(env=None)) |
| 100 | |
| 101 | self.assertRegex( |
| 102 | str(context.exception.output), |
| 103 | "(.*\n)*.*the following arguments are required:(.*)--env(.*\n)*") |
| 104 | |
| 105 | with self.assertRaises(subprocess.CalledProcessError) as context: |
| 106 | self.run_with_output( |
| 107 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 108 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 109 | "--add", "clang", env=None)) |
| 110 | |
| 111 | self.assertRegex( |
| 112 | str(context.exception.output), |
| 113 | "(.*\n)*.*the following arguments are required:(.*)--env(.*\n)*") |
| 114 | |
| 115 | with self.assertRaises(subprocess.CalledProcessError) as context: |
| 116 | self.run_with_output( |
| 117 | self.llvm_projects( |
| 118 | "--remove", "clang", env=None)) |
| 119 | |
| 120 | self.assertRegex( |
| 121 | str(context.exception.output), |
| 122 | "(.*\n)*.*the following arguments are required:(.*)--env(.*\n)*") |
| 123 | |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 124 | def test_dump_empty_config(self): |
| 125 | """ |
| 126 | Test that we're correctly dumping an empty configuration (i.e. no |
| 127 | projects linked) when running llvmprojs without arguments. |
| 128 | """ |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 129 | output = self.run_with_output(self.llvm_projects()) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 130 | self.assertRegex(output, "Projects linked:.*\n.*none.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 131 | |
| 132 | def test_add_remove_subprojects(self): |
| 133 | """ |
| 134 | Test that we can add and remove one or several subprojects. |
| 135 | """ |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 136 | output = self.run_with_output(self.llvm_projects( |
| 137 | "--repos", self.repos, |
| 138 | "--add", "clang")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 139 | self.assertRegex(output, "Projects linked:.*\n.*clang.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 140 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 141 | output = self.run_with_output( |
| 142 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 143 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 144 | "--add", "libcxx", "lldb")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 145 | self.assertRegex( |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 146 | output, |
| 147 | "Projects linked:.*\n" + |
| 148 | ".*clang.*\n" + |
| 149 | ".*libcxx.*\n" + |
| 150 | ".*lldb.*") |
| 151 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 152 | output = self.run_with_output(self.llvm_projects("--remove", "libcxx")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 153 | self.assertRegex(output, |
| 154 | "Projects linked:.*\n" + |
| 155 | ".*clang.*\n" + |
| 156 | ".*lldb.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 157 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 158 | output = self.run_with_output( |
| 159 | self.llvm_projects( |
| 160 | "--remove", "clang", "lldb")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 161 | self.assertRegex(output, |
| 162 | "Projects linked:.*\n" + |
| 163 | ".*none.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 164 | |
| 165 | def test_add_remove_invalid_subprojects(self): |
| 166 | """ |
| 167 | Test that we error out nicely when trying to add/remove invalid |
| 168 | subprojects. |
| 169 | """ |
| 170 | with self.assertRaises(subprocess.CalledProcessError) as context: |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 171 | self.run_with_output( |
| 172 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 173 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 174 | "--add", "inventedsubproject")) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 175 | |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 176 | self.assertRegex( |
| 177 | str(context.exception.output), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 178 | "(.*\n)*.*invalid choice:.*inventedsubproject(.*\n)*") |
| 179 | |
| 180 | with self.assertRaises(subprocess.CalledProcessError) as context: |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 181 | self.run_with_output( |
| 182 | self.llvm_projects( |
| 183 | "--remove", |
| 184 | "inventedsubproject")) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 185 | |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 186 | self.assertRegex( |
| 187 | str(context.exception.output), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 188 | "(.*\n)*.*invalid choice:.*inventedsubproject(.*\n)*") |
| 189 | |
| 190 | def test_duplicate_add_remove(self): |
| 191 | """ |
| 192 | Test that we don't crash when trying to add / remove the same subproject |
| 193 | twice with the same command. |
| 194 | """ |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 195 | output = self.run_with_output( |
| 196 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 197 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 198 | "--add", "clang", "lld", "clang")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 199 | self.assertRegex(output, |
| 200 | "Projects linked:.*\n" + |
| 201 | ".*clang.*\n" + |
| 202 | ".*lld.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 203 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 204 | output = self.run_with_output( |
| 205 | self.llvm_projects( |
| 206 | "--remove", "lld", "lld", "clang")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 207 | self.assertRegex(output, |
| 208 | "Projects linked:.*\n" + |
| 209 | ".*none.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 210 | |
| 211 | def test_redundant_add_remove(self): |
| 212 | """ |
| 213 | Test that we can add a subproject that already exists (either because it |
| 214 | was added by our script or manually) or remove a subproject that doesn't |
| 215 | exist. |
| 216 | """ |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 217 | self.add_worktree(self.get_subproj_repo("clang"), |
| 218 | os.path.join(self.llvm_src, "tools", "clang"), |
| 219 | self.branch) |
| 220 | self.add_worktree( |
| 221 | self.get_subproj_repo("compiler-rt"), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 222 | os.path.join(self.llvm_src, "projects", "compiler-rt"), |
| 223 | self.branch) |
| 224 | |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 225 | output = self.run_with_output(self.llvm_projects( |
| 226 | "--repos", self.repos, |
| 227 | "--add", "clang")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 228 | self.assertRegex(output, |
| 229 | "Projects linked:.*\n" + |
| 230 | ".*clang.*") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 231 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 232 | output = self.run_with_output( |
| 233 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 234 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 235 | "--add", "compiler-rt", "lld")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 236 | self.assertRegex( |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 237 | output, |
| 238 | "Projects linked:.*\n" + |
| 239 | ".*clang.*\n" + |
| 240 | ".*compiler-rt.*\n" + |
| 241 | ".*lld.*") |
| 242 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 243 | output = self.run_with_output( |
| 244 | self.llvm_projects( |
| 245 | "--remove", "lldb", "libcxx", "lld")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 246 | self.assertRegex( |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 247 | output, |
| 248 | "Projects linked:.*\n" + |
| 249 | ".*clang.*\n" + |
| 250 | ".*compiler-rt.*") |
| 251 | |
| 252 | def test_simultaneous_add_remove(self): |
| 253 | """ |
| 254 | Test that we error out when someone is trying to add and remove the same |
| 255 | project with the same command. |
| 256 | """ |
| 257 | # Try the really basic case and make sure we're not touching anything |
| 258 | with self.assertRaises(subprocess.CalledProcessError) as context: |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 259 | self.run_with_output( |
| 260 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 261 | "--repos", |
| 262 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 263 | "--add", |
| 264 | "clang", |
| 265 | "--remove", |
| 266 | "clang")) |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 267 | |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 268 | self.assertRegex( |
| 269 | str(context.exception.output), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 270 | "(.*\n)*.*Can't add and remove clang at the same time(.*\n)*") |
| 271 | |
| 272 | self.assertFalse( |
| 273 | os.path.exists( |
| 274 | os.path.join(self.llvm_src, "tools", "clang"))) |
| 275 | |
| 276 | # Try something a bit more complicated and make sure we're not touching |
| 277 | # anything |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 278 | self.add_worktree( |
| 279 | self.get_subproj_repo("lld"), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 280 | os.path.join(self.llvm_src, "tools", "lld"), |
| 281 | self.branch) |
| 282 | |
| 283 | with self.assertRaises(subprocess.CalledProcessError) as context: |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 284 | self.run_with_output( |
| 285 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 286 | "--repos", |
| 287 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 288 | "--add", |
| 289 | "clang", |
| 290 | "lld", |
| 291 | "libcxx", |
| 292 | "--remove", |
| 293 | "lld", |
| 294 | "libcxx")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 295 | self.assertRegex( |
| 296 | str(context.exception.output), |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 297 | "(.*\n)*" + |
| 298 | ".*Can't add and remove (lld|libcxx) at the same time(.*\n)*") |
| 299 | |
| 300 | # Make sure we didn't touch anything |
| 301 | self.assertFalse( |
| 302 | os.path.exists( |
| 303 | os.path.join(self.llvm_src, "tools", "clang"))) |
| 304 | self.assertTrue( |
| 305 | os.path.exists( |
| 306 | os.path.join(self.llvm_src, "tools", "lld"))) |
| 307 | self.assertFalse( |
| 308 | os.path.exists( |
| 309 | os.path.join(self.llvm_src, "projects", "libcxx"))) |
| 310 | |
| 311 | def test_multiple_adds_removes(self): |
| 312 | """ |
| 313 | Test that we can have multiple --add and --remove options in the same |
| 314 | command and that only the last one of each kind matters. |
| 315 | """ |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 316 | output = self.run_with_output( |
| 317 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 318 | "--repos", |
| 319 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 320 | "--add", |
| 321 | "libcxxabi", |
| 322 | "--remove", |
| 323 | "lld", |
| 324 | "lldb", |
| 325 | "--add", |
| 326 | "clang", |
| 327 | "libcxx", |
| 328 | "--remove", |
| 329 | "libunwind")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 330 | self.assertRegex(output, |
| 331 | "Projects linked:.*\n" + |
| 332 | ".*clang.*\n" + |
| 333 | ".*libcxx.*\n") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 334 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 335 | output = self.run_with_output( |
| 336 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 337 | "--repos", |
| 338 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 339 | "--add", |
| 340 | "libunwind", |
| 341 | "libcxxabi", |
| 342 | "--remove", |
| 343 | "clang", |
| 344 | "libcxx", |
| 345 | "--add", |
| 346 | "compiler-rt", |
| 347 | "--remove", |
| 348 | "libcxxabi")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 349 | self.assertRegex(output, |
| 350 | "Projects linked:.*\n" + |
| 351 | ".*clang.*\n" + |
| 352 | ".*compiler-rt.*\n" + |
| 353 | ".*libcxx.*\n") |
Diana Picus | 3b2ef82 | 2016-10-13 16:53:18 +0300 | [diff] [blame] | 354 | |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 355 | output = self.run_with_output( |
| 356 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 357 | "--repos", |
| 358 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 359 | "--add", |
| 360 | "libcxx", |
| 361 | "--remove", |
| 362 | "lld", |
| 363 | "--add", |
| 364 | "lld", |
| 365 | "--remove", |
| 366 | "libcxx")) |
Diana Picus | b430760 | 2017-04-05 19:48:39 +0200 | [diff] [blame] | 367 | self.assertRegex(output, |
| 368 | "Projects linked:.*\n" + |
| 369 | ".*clang.*\n" + |
| 370 | ".*compiler-rt.*\n" + |
| 371 | ".*lld.*\n") |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 372 | |
| 373 | def test_different_env(self): |
| 374 | """ |
| 375 | Test that we can have different environments in completely different |
| 376 | paths and they don't interfere when we try to add/remove projects. |
| 377 | """ |
| 378 | # Create a separate environment |
| 379 | new_env = mkdtemp() |
| 380 | new_branch = "br" + str(uuid4()) |
Diana Picus | 3601bea | 2017-05-29 11:26:18 +0200 | [diff] [blame] | 381 | self.add_worktree(self.get_subproj_repo("llvm"), |
| 382 | os.path.join(new_env, "llvm"), new_branch) |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 383 | |
| 384 | # Check that we start with a clean slate in both the new environment and |
| 385 | # the one that's already set up |
| 386 | output = self.run_with_output(self.llvm_projects()) |
| 387 | self.assertRegex(output, "Projects linked:.*\n.*none.*") |
| 388 | |
| 389 | output = self.run_with_output(self.llvm_projects(env=new_env)) |
| 390 | self.assertRegex(output, "Projects linked:.*\n.*none.*") |
| 391 | |
| 392 | # Make sure that adding projects works |
| 393 | output = self.run_with_output( |
| 394 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 395 | "--repos", self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 396 | "--add", "clang", "lld")) |
| 397 | self.assertRegex(output, "Projects linked:.*\n.*clang.*\n.*lld.*\n") |
| 398 | |
| 399 | output = self.run_with_output( |
| 400 | self.llvm_projects( |
Diana Picus | adb07c4 | 2017-11-22 16:12:57 +0100 | [diff] [blame] | 401 | "--repos", |
| 402 | self.repos, |
Diana Picus | 81089db | 2017-05-05 22:26:49 +0200 | [diff] [blame] | 403 | "--add", |
| 404 | "libcxx", |
| 405 | "libcxxabi", |
| 406 | env=new_env)) |
| 407 | self.assertRegex(output, |
| 408 | "Projects linked:.*\n.*libcxx.*\n.*libcxxabi.*\n.*") |
| 409 | |
| 410 | output = self.run_with_output(self.llvm_projects()) |
| 411 | self.assertRegex(output, "Projects linked:.*\n.*clang.*\n.*lld.*\n") |
| 412 | |
| 413 | # Make sure that removing projects works |
| 414 | output = self.run_with_output(self.llvm_projects("--remove", "lld")) |
| 415 | self.assertRegex(output, "Projects linked:.*\n.*clang.*\n") |
| 416 | |
| 417 | output = self.run_with_output(self.llvm_projects("--remove", "libcxx", |
| 418 | env=new_env)) |
| 419 | self.assertRegex(output, |
| 420 | "Projects linked:.*\n.*libcxxabi.*\n.*") |
| 421 | |
| 422 | output = self.run_with_output(self.llvm_projects()) |
| 423 | self.assertRegex(output, "Projects linked:.*\n.*clang.*\n") |
| 424 | |
| 425 | shutil.rmtree(new_env) |