diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/testing/__init__.py | 2 | ||||
-rw-r--r-- | src/buildstream/testing/_yaml.py | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/buildstream/testing/__init__.py b/src/buildstream/testing/__init__.py index 46cadbbfa..dafc3a9fe 100644 --- a/src/buildstream/testing/__init__.py +++ b/src/buildstream/testing/__init__.py @@ -22,6 +22,8 @@ This package contains various utilities which make it easier to test plugins. import os from collections import OrderedDict from buildstream.exceptions import ErrorDomain, LoadErrorReason +from buildstream._yaml import load as load_yaml # type: ignore +from ._yaml import generate_project, generate_element from .repo import Repo from .runcli import cli, cli_integration, cli_remote_execution from .integration import integration_cache diff --git a/src/buildstream/testing/_yaml.py b/src/buildstream/testing/_yaml.py new file mode 100644 index 000000000..ccf65a1ae --- /dev/null +++ b/src/buildstream/testing/_yaml.py @@ -0,0 +1,19 @@ +import os + +from buildstream._yaml import roundtrip_dump # type: ignore + + +def generate_project(project_dir, config=None): + if config is None: + config = {} + project_file = os.path.join(project_dir, "project.conf") + if "name" not in config: + config["name"] = os.path.basename(project_dir) + roundtrip_dump(config, project_file) + + +def generate_element(element_dir, element_name, config=None): + if config is None: + config = {} + element_path = os.path.join(element_dir, element_name) + roundtrip_dump(config, element_path) |