Move --repos flag to projects subcommand
The --repos flag is not used by all the subcommands, so there's no
reason for it to be compulsory. This commit moves it from the generic
llvm.py options to the options for the projects subcommand, where it is
only required when adding subprojects.
Change-Id: I7ad10bda6e1b4efeb594b09e5fda200850d99c07
diff --git a/tests/cli/llvmtestcase.py b/tests/cli/llvmtestcase.py
index 9b4ac3e..a6f234d 100644
--- a/tests/cli/llvmtestcase.py
+++ b/tests/cli/llvmtestcase.py
@@ -84,18 +84,11 @@
def command_with_defaults(cls, subcommand, *args, **kwargs):
"""
Build a list representing a llvm subcommand with the given
- args. Unless otherwise specified in kwargs, this uses the values for
- repos and env that it finds in cls.
+ args. Unless otherwise specified in kwargs, this uses the value for
+ env that it finds in cls.
"""
command = [cls.python, cls.script]
- repos = cls.repos
- if "repos" in kwargs:
- repos = kwargs["repos"]
- if repos:
- command.append("--repos")
- command.append(repos)
-
env = cls.env
if "env" in kwargs:
env = kwargs["env"]
diff --git a/tests/cli/testllvmprojects.py b/tests/cli/testllvmprojects.py
index 30f7ff2..ac1cd23 100644
--- a/tests/cli/testllvmprojects.py
+++ b/tests/cli/testllvmprojects.py
@@ -72,37 +72,23 @@
with cd(repopath):
cls.run_quietly(["git", "worktree", "prune"])
- def test_repos_arg_is_compulsory(self):
+ def test_repos_arg_is_compulsory_for_add(self):
"""
- Test that we must pass in the repos for various combinations of input
- args.
+ Test that we must pass in the repos when adding a subproject, but not
+ for other combinations of arguments.
"""
with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output(self.llvm_projects(repos=None))
-
- self.assertRegex(
- str(context.exception.output),
- "(.*\n)*.*the following arguments are required:(.*)--repos(.*\n)*")
-
- with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_with_output(
- self.llvm_projects(
- "--add", "clang", repos=None))
+ self.llvm_projects("--add", "clang"))
self.assertRegex(
str(context.exception.output),
- "(.*\n)*.*the following arguments are required:(.*)--repos(.*\n)*")
+ "(.*\n)*.*When adding a subproject you must also pass the --repos argument(.*\n)*")
- with self.assertRaises(subprocess.CalledProcessError) as context:
- self.run_with_output(
- self.llvm_projects(
- "--remove",
- "clang",
- repos=None))
-
- self.assertRegex(
- str(context.exception.output),
- "(.*\n)*.*the following arguments are required:(.*)--repos(.*\n)*")
+ # These should not raise.
+ self.run_with_output(self.llvm_projects())
+ self.run_with_output(
+ self.llvm_projects("--remove", "clang"))
def test_env_arg_is_compulsory(self):
"""
@@ -119,6 +105,7 @@
with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "clang", env=None))
self.assertRegex(
@@ -146,11 +133,14 @@
"""
Test that we can add and remove one or several subprojects.
"""
- output = self.run_with_output(self.llvm_projects("--add", "clang"))
+ output = self.run_with_output(self.llvm_projects(
+ "--repos", self.repos,
+ "--add", "clang"))
self.assertRegex(output, "Projects linked:.*\n.*clang.*")
output = self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "libcxx", "lldb"))
self.assertRegex(
output,
@@ -180,6 +170,7 @@
with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "inventedsubproject"))
self.assertRegex(
@@ -203,6 +194,7 @@
"""
output = self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "clang", "lld", "clang"))
self.assertRegex(output,
"Projects linked:.*\n" +
@@ -230,13 +222,16 @@
os.path.join(self.llvm_src, "projects", "compiler-rt"),
self.branch)
- output = self.run_with_output(self.llvm_projects("--add", "clang"))
+ output = self.run_with_output(self.llvm_projects(
+ "--repos", self.repos,
+ "--add", "clang"))
self.assertRegex(output,
"Projects linked:.*\n" +
".*clang.*")
output = self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "compiler-rt", "lld"))
self.assertRegex(
output,
@@ -263,6 +258,8 @@
with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"clang",
"--remove",
@@ -286,6 +283,8 @@
with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"clang",
"lld",
@@ -316,6 +315,8 @@
"""
output = self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"libcxxabi",
"--remove",
@@ -333,6 +334,8 @@
output = self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"libunwind",
"libcxxabi",
@@ -351,6 +354,8 @@
output = self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"libcxx",
"--remove",
@@ -387,11 +392,14 @@
# Make sure that adding projects works
output = self.run_with_output(
self.llvm_projects(
+ "--repos", self.repos,
"--add", "clang", "lld"))
self.assertRegex(output, "Projects linked:.*\n.*clang.*\n.*lld.*\n")
output = self.run_with_output(
self.llvm_projects(
+ "--repos",
+ self.repos,
"--add",
"libcxx",
"libcxxabi",