aboutsummaryrefslogtreecommitdiff
path: root/tests/cli/llvmtestcase.py
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-06-09 19:14:08 +0200
committerDiana Picus <diana.picus@linaro.org>2017-07-07 18:08:56 +0200
commitefc7bdaf3f4e53b0b9c15c4b1100dcf2e9d30b09 (patch)
tree50ab59c5106a23a2f11ee9478407f278afc520b4 /tests/cli/llvmtestcase.py
parent3601bea50533d4ba06fafac16664183cdb250ab0 (diff)
[llvmpush] Add llvm push
Add support for pushing the current branch in all linked subprojects in a given config. If they are not on the same branch, an error is thrown. The branches are pushed as linaro-local/$user/$branch, where $branch is the local name of the branch and $user is the user as seen in LLVM_GITUSER (we might want to change to a more intelligent way to get the user in the future). We achieve this by adding a new method to LLVMSourceConfig: for_each_enabled, which takes an action and applies it to all the enabled subprojects. If an exception is thrown by the action, it is rethrown by the action as a RuntimeError specifying which project the action was being applied to. Note that this does not behave like a transaction - the action may have been applied to some of the projects already, and there's no way to undo it. It's also a bit difficult to tell which projects the action was applied on (in the future we should probably log that info). We also provide an action that simply pushes the current branch to origin with the updated name. This makes sure the remote branch will live in an isolated namespace where it won't conflict with other people's branches. We also update some of the internals of LLVMSourceConfig to throw exceptions if some of the subprojects that are linked are not worktrees on the same branch as LLVM. In the past they were just ignored, but that doesn't seem like a sane default anymore. Change-Id: I9c917658d65b5d0e7bad3310efce07a0fe5bce5e
Diffstat (limited to 'tests/cli/llvmtestcase.py')
-rw-r--r--tests/cli/llvmtestcase.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/tests/cli/llvmtestcase.py b/tests/cli/llvmtestcase.py
index b2fc765..9b4ac3e 100644
--- a/tests/cli/llvmtestcase.py
+++ b/tests/cli/llvmtestcase.py
@@ -34,19 +34,28 @@ class LLVMTestCase(unittest.TestCase):
script = os.path.join("scripts", "llvm.py")
@classmethod
- def create_dummy_commit(cls):
- filename = "filethatshouldntexist"
+ def create_dummy_commit(cls, commitMessage="Dummy commit"):
+ filename = "filethatshouldntexist" + str(uuid4())
cls.run_quietly(["touch", filename])
- cls.run_quietly(["git", "add", filename])
- cls.run_quietly(["git", "commit", "-m", "Dummy commit"])
+ try:
+ cls.run_quietly(["git", "add", filename])
+ cls.run_quietly(["git", "commit", "-m", commitMessage])
+ except subprocess.CalledProcessError as exc:
+ print("Command {} exited with error code {}:\n{}".format(
+ exc.cmd, exc.returncode, exc.output))
@classmethod
- def create_dummy_repo(cls, repopath):
- if not os.path.isdir(repopath):
- os.makedirs(repopath)
+ def create_dummy_repo(cls, repopath, originpath=None):
+ if originpath is not None:
+ cls.run_quietly(["git", "clone", originpath, repopath])
+ else:
+ if not os.path.isdir(repopath):
+ os.makedirs(repopath)
+
+ with cd(repopath):
+ cls.run_quietly(["git", "init"])
with cd(repopath):
- cls.run_quietly(["git", "init"])
cls.create_dummy_commit()
@classmethod
@@ -55,10 +64,6 @@ class LLVMTestCase(unittest.TestCase):
cls.run_quietly(["git", "worktree", "add", worktreepath,
"-b", branch])
- @classmethod
- def get_subproj_repo(cls, subproj):
- return os.path.join(cls.repos, subproj)
-
@staticmethod
def run_with_output(*args, **kwargs):
"""Helper for running a command and capturing stdout and stderr"""