diff options
Diffstat (limited to 'tests/testutils/runcli.py')
-rw-r--r-- | tests/testutils/runcli.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py index f165232dc..202766fb3 100644 --- a/tests/testutils/runcli.py +++ b/tests/testutils/runcli.py @@ -1,5 +1,7 @@ import os +import re import sys +import shutil import itertools import traceback from contextlib import contextmanager, ExitStack @@ -7,6 +9,8 @@ from click.testing import CliRunner from ruamel import yaml import pytest +from tests.testutils.site import IS_LINUX + # Import the main cli entrypoint from buildstream._frontend.main import cli as bst_cli from buildstream import _yaml @@ -24,6 +28,17 @@ class Result(): self.exception = _get_last_exception() self.result = result + ################################################################## + # Result parsers # + ################################################################## + def get_tracked_elements(self): + tracked = re.findall(r'\[track:(\S+)\s*]', + self.result.output) + if tracked is None: + return [] + + return list(tracked) + class Cli(): @@ -44,6 +59,17 @@ class Cli(): def configure(self, config): self.config = config + def remove_artifact_from_cache(self, project, element_name): + cache_dir = os.path.join(project, 'cache', 'artifacts') + + if IS_LINUX: + cache_dir = os.path.join(cache_dir, 'ostree', 'refs', 'heads') + else: + cache_dir = os.path.join(cache_dir, 'tar') + + cache_dir = os.path.splitext(os.path.join(cache_dir, 'test', element_name))[0] + shutil.rmtree(cache_dir) + # run(): # # Runs buildstream with the given arguments, additionally |