summaryrefslogtreecommitdiff
path: root/src/buildstream
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream')
-rw-r--r--src/buildstream/_context.py7
-rw-r--r--src/buildstream/_frontend/cli.py2
-rw-r--r--src/buildstream/_project.py4
-rw-r--r--src/buildstream/_workspaces.py2
-rw-r--r--src/buildstream/_yaml.pyx2
-rw-r--r--src/buildstream/testing/__init__.py3
-rw-r--r--src/buildstream/testing/_sourcetests/mirror.py4
-rw-r--r--src/buildstream/testing/_sourcetests/track.py2
-rw-r--r--src/buildstream/testing/_yaml.py9
-rw-r--r--src/buildstream/testing/runcli.py2
10 files changed, 21 insertions, 16 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index c0e92b98e..8b559153e 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -233,11 +233,14 @@ class Context:
# Load default config
#
- defaults = _yaml.load(_site.default_user_config)
+ defaults = _yaml.load(_site.default_user_config, shortname="userconfig.yaml")
if config:
self.config_origin = os.path.abspath(config)
- user_config = _yaml.load(config)
+
+ # Here we use the fullpath as the shortname as well, as it is useful to have
+ # a fullpath displayed in errors for the user configuration
+ user_config = _yaml.load(config, shortname=config)
user_config._composite(defaults)
# Give obsoletion warnings
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index ff68af66d..20914f15d 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -120,7 +120,7 @@ def complete_target(args, incomplete):
else:
project_file = os.path.join(base_directory, project_conf)
try:
- project = _yaml.load(project_file)
+ project = _yaml.load(project_file, shortname=project_conf)
except LoadError:
# If there is no project conf in context, just dont
# even bother trying to complete anything.
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index b45c6c695..76f30735a 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -747,11 +747,11 @@ class Project:
# Load builtin default
projectfile = os.path.join(self.directory, _PROJECT_CONF_FILE)
- self._default_config_node = _yaml.load(_site.default_project_config)
+ self._default_config_node = _yaml.load(_site.default_project_config, shortname="projectconfig.yaml")
# Load project local config and override the builtin
try:
- self._project_conf = _yaml.load(projectfile)
+ self._project_conf = _yaml.load(projectfile, shortname=_PROJECT_CONF_FILE, project=self)
except LoadError as e:
# Raise a more specific error here
if e.reason == LoadErrorReason.MISSING_FILE:
diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py
index a54a17ff1..f1fc353a7 100644
--- a/src/buildstream/_workspaces.py
+++ b/src/buildstream/_workspaces.py
@@ -449,7 +449,7 @@ class Workspaces:
def _load_config(self):
workspace_file = self._get_filename()
try:
- node = _yaml.load(workspace_file)
+ node = _yaml.load(workspace_file, shortname="workspaces.yml")
except LoadError as e:
if e.reason == LoadErrorReason.MISSING_FILE:
# Return an empty dict if there was no workspace file
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 1e59b2a1c..17524cd1b 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -255,7 +255,7 @@ cdef class Representer:
#
# Raises: LoadError
#
-cpdef MappingNode load(str filename, str shortname=None, bint copy_tree=False, object project=None):
+cpdef MappingNode load(str filename, str shortname, bint copy_tree=False, object project=None):
cdef MappingNode data
if not shortname:
diff --git a/src/buildstream/testing/__init__.py b/src/buildstream/testing/__init__.py
index f09c5bda1..19c19a64c 100644
--- a/src/buildstream/testing/__init__.py
+++ b/src/buildstream/testing/__init__.py
@@ -22,8 +22,7 @@ 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 ._yaml import generate_project, generate_element, load_yaml
from .repo import Repo
from .runcli import cli, cli_integration, cli_remote_execution
from .integration import integration_cache
diff --git a/src/buildstream/testing/_sourcetests/mirror.py b/src/buildstream/testing/_sourcetests/mirror.py
index 69042747c..836ef0580 100644
--- a/src/buildstream/testing/_sourcetests/mirror.py
+++ b/src/buildstream/testing/_sourcetests/mirror.py
@@ -255,7 +255,7 @@ def test_mirror_track_upstream_present(cli, tmpdir, datafiles, kind):
result.assert_success()
# Tracking tries upstream first. Check the ref is from upstream.
- new_element = _yaml.load(element_path)
+ new_element = _yaml.load(element_path, shortname=element_name)
source = new_element.get_sequence("sources").mapping_at(0)
if "ref" in source:
assert source.get_str("ref") == upstream_ref
@@ -300,7 +300,7 @@ def test_mirror_track_upstream_absent(cli, tmpdir, datafiles, kind):
result.assert_success()
# Check that tracking fell back to the mirror
- new_element = _yaml.load(element_path)
+ new_element = _yaml.load(element_path, shortname=element_name)
source = new_element.get_sequence("sources").mapping_at(0)
if "ref" in source:
assert source.get_str("ref") == mirror_ref
diff --git a/src/buildstream/testing/_sourcetests/track.py b/src/buildstream/testing/_sourcetests/track.py
index ecb508b1a..38ef217f0 100644
--- a/src/buildstream/testing/_sourcetests/track.py
+++ b/src/buildstream/testing/_sourcetests/track.py
@@ -284,7 +284,7 @@ def test_track_include(cli, tmpdir, datafiles, ref_storage, kind):
else:
assert not os.path.exists(os.path.join(project, "project.refs"))
- new_sources = _yaml.load(os.path.join(element_path, "sources.yml"))
+ new_sources = _yaml.load(os.path.join(element_path, "sources.yml"), shortname="sources.yml")
# Get all of the sources
assert "sources" in new_sources
diff --git a/src/buildstream/testing/_yaml.py b/src/buildstream/testing/_yaml.py
index 0a16f3226..396266b85 100644
--- a/src/buildstream/testing/_yaml.py
+++ b/src/buildstream/testing/_yaml.py
@@ -1,6 +1,9 @@
import os
+from buildstream import _yaml
-from buildstream._yaml import roundtrip_dump # type: ignore
+
+def load_yaml(filename):
+ return _yaml.load(filename, shortname=os.path.basename(filename))
def generate_project(project_dir, config=None):
@@ -11,11 +14,11 @@ def generate_project(project_dir, config=None):
config["name"] = os.path.basename(project_dir)
if "min-version" not in config:
config["min-version"] = "2.0"
- roundtrip_dump(config, project_file)
+ _yaml.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)
+ _yaml.roundtrip_dump(config, element_path)
diff --git a/src/buildstream/testing/runcli.py b/src/buildstream/testing/runcli.py
index 712e6811a..0f08bd141 100644
--- a/src/buildstream/testing/runcli.py
+++ b/src/buildstream/testing/runcli.py
@@ -539,7 +539,7 @@ class CliIntegration(Cli):
with open(temp_project, "w") as f:
yaml.safe_dump(project_config, f)
- project_config = _yaml.load(temp_project)
+ project_config = _yaml.load(temp_project, shortname="project.conf")
project_config._composite(base_config)