summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/pipeline/preflight-error/error.bst4
-rw-r--r--tests/pipeline/preflight-error/errorplugin/__init__.py0
-rw-r--r--tests/pipeline/preflight-error/errorplugin/preflighterror.py35
-rw-r--r--tests/pipeline/preflight-error/project.conf11
-rw-r--r--tests/pipeline/preflight.py19
5 files changed, 69 insertions, 0 deletions
diff --git a/tests/pipeline/preflight-error/error.bst b/tests/pipeline/preflight-error/error.bst
new file mode 100644
index 000000000..a9772770c
--- /dev/null
+++ b/tests/pipeline/preflight-error/error.bst
@@ -0,0 +1,4 @@
+kind: import
+description: An element with a failing source at preflight time
+sources:
+- kind: preflighterror
diff --git a/tests/pipeline/preflight-error/errorplugin/__init__.py b/tests/pipeline/preflight-error/errorplugin/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/pipeline/preflight-error/errorplugin/__init__.py
diff --git a/tests/pipeline/preflight-error/errorplugin/preflighterror.py b/tests/pipeline/preflight-error/errorplugin/preflighterror.py
new file mode 100644
index 000000000..59c49e012
--- /dev/null
+++ b/tests/pipeline/preflight-error/errorplugin/preflighterror.py
@@ -0,0 +1,35 @@
+from buildstream import Source, SourceError, Consistency
+
+
+class PreflightErrorSource(Source):
+
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+
+ # Raise a preflight error unconditionally
+ raise SourceError("{}: Unsatisfied requirements in preflight, raising this error",
+ reason="the-preflight-error")
+
+ def get_unique_key(self):
+ return {}
+
+ def get_consistency(self):
+ return Consistency.CACHED
+
+ def get_ref(self):
+ return None
+
+ def set_ref(self, ref, node):
+ pass
+
+ def fetch(self):
+ pass
+
+ def stage(self, directory):
+ pass
+
+
+def setup():
+ return PreflightErrorSource
diff --git a/tests/pipeline/preflight-error/project.conf b/tests/pipeline/preflight-error/project.conf
new file mode 100644
index 000000000..20a234413
--- /dev/null
+++ b/tests/pipeline/preflight-error/project.conf
@@ -0,0 +1,11 @@
+# Basic project configuration that doesnt override anything
+#
+name: pony
+
+# Whitelist the local test Source "errorplugin" to be loaded
+#
+plugins:
+- origin: local
+ path: errorplugin
+ sources:
+ preflighterror: 0
diff --git a/tests/pipeline/preflight.py b/tests/pipeline/preflight.py
new file mode 100644
index 000000000..f9eb649ff
--- /dev/null
+++ b/tests/pipeline/preflight.py
@@ -0,0 +1,19 @@
+import os
+import pytest
+
+from buildstream._exceptions import ErrorDomain
+from tests.testutils.runcli import cli
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ 'preflight-error',
+)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_load_simple(cli, datafiles, tmpdir):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+
+ # Lets try to fetch it...
+ result = cli.run(project=basedir, args=['fetch', 'error.bst'])
+ result.assert_main_error(ErrorDomain.PIPELINE, "the-preflight-error")