Remove the need for LLVM_SRC in llvm.py
Add an extra parameter to llvm.py representing the environment that we
want the command to refer to. We then compute the path to the LLVM
source tree based on that and LLVM_ROOT (which is still an environment
variable for the time being).
The bash helper keeps its old interface and uses LLVM_SRC to compute the
environment that it will pass down to llvm.py. We also perform a small
number of drive-by fixes to this helper (e.g. replacing python with
python3).
Change-Id: Ie7a33103969622294e158f83be8b9f57832ef1dc
diff --git a/tests/cli/testllvmprojects.py b/tests/cli/testllvmprojects.py
index e8bb860..8374aff 100644
--- a/tests/cli/testllvmprojects.py
+++ b/tests/cli/testllvmprojects.py
@@ -99,7 +99,8 @@
@classmethod
def setUp(cls):
- cls.llvm_src = os.path.join(cls.llvm_root, "src" + str(uuid4()))
+ cls.env = "src" + str(uuid4())
+ cls.llvm_src = os.path.join(cls.llvm_root, cls.env, "llvm")
# Create LLVM worktree
cls.branch = "br" + str(uuid4())
@@ -108,7 +109,6 @@
# Set up the environment variables
os.environ["LLVM_ROOT"] = cls.llvm_root
- os.environ["LLVM_SRC"] = cls.llvm_src
@classmethod
def tearDown(cls):
@@ -133,18 +133,19 @@
Test that we're correctly dumping an empty configuration (i.e. no
projects linked) when running llvmprojs without arguments.
"""
- output = self.run_with_output([self.python, self.script, "projects"])
+ output = self.run_with_output(
+ [self.python, self.script, self.env, "projects"])
self.assertRegex(output, "Projects linked:.*\n.*none.*")
def test_add_remove_subprojects(self):
"""
Test that we can add and remove one or several subprojects.
"""
- output = self.run_with_output([self.python, self.script, "projects",
- "--add", "clang"])
+ output = self.run_with_output(
+ [self.python, self.script, self.env, "projects", "--add", "clang"])
self.assertRegex(output, "Projects linked:.*\n.*clang.*")
- output = self.run_with_output([self.python, self.script, "projects",
+ output = self.run_with_output([self.python, self.script, self.env, "projects",
"--add", "libcxx", "lldb"])
self.assertRegex(
output,
@@ -153,14 +154,14 @@
".*libcxx.*\n" +
".*lldb.*")
- output = self.run_with_output([self.python, self.script, "projects",
- "--remove", "libcxx"])
+ output = self.run_with_output(
+ [self.python, self.script, self.env, "projects", "--remove", "libcxx"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*\n" +
".*lldb.*")
- output = self.run_with_output([self.python, self.script, "projects",
+ output = self.run_with_output([self.python, self.script, self.env, "projects",
"--remove", "clang", "lldb"])
self.assertRegex(output,
"Projects linked:.*\n" +
@@ -172,7 +173,7 @@
subprojects.
"""
with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output([self.python, self.script, "projects",
+ self.run_with_output([self.python, self.script, self.env, "projects",
"--add", "inventedsubproject"])
self.assertRegex(
@@ -180,8 +181,12 @@
"(.*\n)*.*invalid choice:.*inventedsubproject(.*\n)*")
with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output([self.python, self.script, "projects",
- "--remove", "inventedsubproject"])
+ self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--remove",
+ "inventedsubproject"])
self.assertRegex(
str(context.exception.output),
@@ -192,14 +197,14 @@
Test that we don't crash when trying to add / remove the same subproject
twice with the same command.
"""
- output = self.run_with_output([self.python, self.script, "projects",
+ output = self.run_with_output([self.python, self.script, self.env, "projects",
"--add", "clang", "lld", "clang"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*\n" +
".*lld.*")
- output = self.run_with_output([self.python, self.script, "projects",
+ output = self.run_with_output([self.python, self.script, self.env, "projects",
"--remove", "lld", "lld", "clang"])
self.assertRegex(output,
"Projects linked:.*\n" +
@@ -219,13 +224,13 @@
os.path.join(self.llvm_src, "projects", "compiler-rt"),
self.branch)
- output = self.run_with_output([self.python, self.script, "projects",
- "--add", "clang"])
+ output = self.run_with_output(
+ [self.python, self.script, self.env, "projects", "--add", "clang"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*")
- output = self.run_with_output([self.python, self.script, "projects",
+ output = self.run_with_output([self.python, self.script, self.env, "projects",
"--add", "compiler-rt", "lld"])
self.assertRegex(
output,
@@ -234,8 +239,14 @@
".*compiler-rt.*\n" +
".*lld.*")
- output = self.run_with_output([self.python, self.script, "projects",
- "--remove", "lldb", "libcxx", "lld"])
+ output = self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--remove",
+ "lldb",
+ "libcxx",
+ "lld"])
self.assertRegex(
output,
"Projects linked:.*\n" +
@@ -249,8 +260,14 @@
"""
# Try the really basic case and make sure we're not touching anything
with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output([self.python, self.script, "projects",
- "--add", "clang", "--remove", "clang"])
+ self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--add",
+ "clang",
+ "--remove",
+ "clang"])
self.assertRegex(
str(context.exception.output),
@@ -268,9 +285,17 @@
self.branch)
with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output([self.python, self.script, "projects",
- "--add", "clang", "lld", "libcxx",
- "--remove", "lld", "libcxx"])
+ self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--add",
+ "clang",
+ "lld",
+ "libcxx",
+ "--remove",
+ "lld",
+ "libcxx"])
self.assertRegex(
str(context.exception.output),
"(.*\n)*" +
@@ -292,30 +317,57 @@
Test that we can have multiple --add and --remove options in the same
command and that only the last one of each kind matters.
"""
- output = self.run_with_output([self.python, self.script, "projects",
- "--add", "libcxxabi",
- "--remove", "lld", "lldb",
- "--add", "clang", "libcxx",
- "--remove", "libunwind"])
+ output = self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--add",
+ "libcxxabi",
+ "--remove",
+ "lld",
+ "lldb",
+ "--add",
+ "clang",
+ "libcxx",
+ "--remove",
+ "libunwind"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*\n" +
".*libcxx.*\n")
- output = self.run_with_output([self.python, self.script, "projects",
- "--add", "libunwind", "libcxxabi",
- "--remove", "clang", "libcxx",
- "--add", "compiler-rt",
- "--remove", "libcxxabi"])
+ output = self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--add",
+ "libunwind",
+ "libcxxabi",
+ "--remove",
+ "clang",
+ "libcxx",
+ "--add",
+ "compiler-rt",
+ "--remove",
+ "libcxxabi"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*\n" +
".*compiler-rt.*\n" +
".*libcxx.*\n")
- output = self.run_with_output([self.python, self.script, "projects",
- "--add", "libcxx", "--remove", "lld",
- "--add", "lld", "--remove", "libcxx"])
+ output = self.run_with_output([self.python,
+ self.script,
+ self.env,
+ "projects",
+ "--add",
+ "libcxx",
+ "--remove",
+ "lld",
+ "--add",
+ "lld",
+ "--remove",
+ "libcxx"])
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*\n" +