aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-03-14 17:38:32 +0100
committerDiana Picus <diana.picus@linaro.org>2017-04-24 15:48:56 +0200
commit3d1a30130a581e68afdbc027c82c5b1cd662ea6e (patch)
tree261513090b45c402f25e0f44931fcfca6db082fb /tests
parentb430760d782ac5a4e1270d49038d0f400a3506c0 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/testllvmprojects.py126
1 files changed, 89 insertions, 37 deletions
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 @@ class Testllvmprojs(unittest.TestCase):
@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 @@ class Testllvmprojs(unittest.TestCase):
# 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 @@ class Testllvmprojs(unittest.TestCase):
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 @@ class Testllvmprojs(unittest.TestCase):
".*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 @@ class Testllvmprojs(unittest.TestCase):
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 @@ class Testllvmprojs(unittest.TestCase):
"(.*\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 @@ class Testllvmprojs(unittest.TestCase):
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 @@ class Testllvmprojs(unittest.TestCase):
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 @@ class Testllvmprojs(unittest.TestCase):
".*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 @@ class Testllvmprojs(unittest.TestCase):
"""
# 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 @@ class Testllvmprojs(unittest.TestCase):
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 @@ class Testllvmprojs(unittest.TestCase):
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" +