summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-21 19:23:04 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-03-21 23:38:07 +0900
commitcf43f8cff1c1d1e7eccfc438f71f5741c9be3f08 (patch)
tree49c1d0d4db02de6891d07c4277b14bd7bcec7f28
parent96c5c427c0f61050dac14692bd269084d275eb9b (diff)
downloadbuildstream-cf43f8cff1c1d1e7eccfc438f71f5741c9be3f08.tar.gz
tests/frontend/fetch.py: Test failure modes of Source.get_consistency()
Added a test that handled errors are reported at load time as expected. Added another test that we get the expected exception. This needs to be fixed, test contains FIXME: comment explaining that we could be doing much better here. This should be fixed in the context of issue #197
-rw-r--r--tests/frontend/fetch.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index 6f497fdab..8b44690b4 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -3,12 +3,11 @@ import pytest
from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
+from buildstream._exceptions import ErrorDomain
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
+TOP_DIR = os.path.dirname(os.path.realpath(__file__))
+DATA_DIR = os.path.join(TOP_DIR, 'project')
@pytest.mark.datafiles(DATA_DIR)
@@ -46,3 +45,29 @@ def test_fetch(cli, tmpdir, datafiles, kind):
# Assert that we are now buildable because the source is
# now cached.
assert cli.get_element_state(project, element_name) == 'buildable'
+
+
+@pytest.mark.datafiles(os.path.join(TOP_DIR, 'consistencyerror'))
+def test_fetch_consistency_error(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ # When the error occurs outside of the scheduler at load time,
+ # then the SourceError is reported directly as the main error.
+ result = cli.run(project=project, args=['fetch', 'error.bst'])
+ result.assert_main_error(ErrorDomain.SOURCE, 'the-consistency-error')
+
+
+@pytest.mark.datafiles(os.path.join(TOP_DIR, 'consistencyerror'))
+def test_fetch_consistency_bug(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ # FIXME:
+ #
+ # When a plugin raises an unhandled exception at load
+ # time, as is the case when running Source.get_consistency()
+ # for a fetch command, we could report this to the user
+ # more gracefully as a BUG message.
+ #
+ result = cli.run(project=project, args=['fetch', 'bug.bst'])
+ assert result.exc is not None
+ assert str(result.exc) == "Something went terribly wrong"