summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-05-10 13:40:28 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-05-10 13:40:28 +0000
commit92555c4e7baf36c1619336ade271be6b41cc3af5 (patch)
tree86eaa2d231339f58fbdce3e5293feadcf854d50a
parent34268dd10146c4cf0dd3e5c4b580a2a583e9edec (diff)
parent9489e061314fdd81f049d58c733913fed84b2c8e (diff)
downloadbuildstream-92555c4e7baf36c1619336ade271be6b41cc3af5.tar.gz
Merge branch 'coldtom/backport-MR792' into 'bst-1.2'
Backport !792 to bst-1.2 See merge request BuildStream/buildstream!1338
-rw-r--r--buildstream/_project.py5
-rw-r--r--tests/format/project.py7
-rw-r--r--tests/format/project/invalid-yaml/manual.bst1
-rw-r--r--tests/format/project/invalid-yaml/project.conf8
4 files changed, 20 insertions, 1 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 4a3c075e0..c9325174d 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -381,7 +381,10 @@ class Project():
self._project_conf = _yaml.load(projectfile)
except LoadError as e:
# Raise a more specific error here
- raise LoadError(LoadErrorReason.MISSING_PROJECT_CONF, str(e))
+ if e.reason == LoadErrorReason.MISSING_FILE:
+ raise LoadError(LoadErrorReason.MISSING_PROJECT_CONF, str(e)) from e
+ else:
+ raise
pre_config_node = _yaml.node_copy(self._default_config_node)
_yaml.composite(pre_config_node, self._project_conf)
diff --git a/tests/format/project.py b/tests/format/project.py
index abd0c4238..83fd38489 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -61,6 +61,13 @@ def test_invalid_project_name(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
+def test_invalid_yaml(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename, "invalid-yaml")
+ result = cli.run(project=project, args=['workspace', 'list'])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_YAML)
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_load_default_project(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "default")
result = cli.run(project=project, args=[
diff --git a/tests/format/project/invalid-yaml/manual.bst b/tests/format/project/invalid-yaml/manual.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/project/invalid-yaml/manual.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/project/invalid-yaml/project.conf b/tests/format/project/invalid-yaml/project.conf
new file mode 100644
index 000000000..5f9282bbf
--- /dev/null
+++ b/tests/format/project/invalid-yaml/project.conf
@@ -0,0 +1,8 @@
+# Basic project configuration that doesnt override anything
+#
+
+name: pony
+
+variables:
+ sbindir: "%{bindir}
+