summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-03 20:50:15 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-03 22:49:11 +0900
commit01db40724a6ff0e69bdde02f5720479b1b503b3b (patch)
treeec39eccc6984e15519e5ef2a90c42edeaf75c940
parent500f4f330fde8b6001a2f8d8921bd5b8acb79960 (diff)
downloadbuildstream-01db40724a6ff0e69bdde02f5720479b1b503b3b.tar.gz
_exceptions.py: Adhere to policy on private symbols
And adjust all surrounding sources for changed symbols. Also, added new LoadErrorReason.UNSUPPORTED_PLUGIN, required for changes in how the project will report format version errors for plugins at creation time This is a part of issue #285
-rw-r--r--buildstream/_exceptions.py38
-rw-r--r--buildstream/_scheduler/job.py6
-rw-r--r--buildstream/_scheduler/queue.py4
-rw-r--r--tests/testutils/runcli.py6
4 files changed, 37 insertions, 17 deletions
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py
index 27045bece..8ed96ec98 100644
--- a/buildstream/_exceptions.py
+++ b/buildstream/_exceptions.py
@@ -29,7 +29,13 @@ _last_task_error_domain = None
_last_task_error_reason = None
-def _get_last_exception():
+# get_last_exception()
+#
+# Fetches the last exception from the main process
+#
+# Used by regression tests
+#
+def get_last_exception():
global _last_exception
le = _last_exception
@@ -37,8 +43,13 @@ def _get_last_exception():
return le
-# Called from regression test fixtures
-def _get_last_task_error():
+# get_last_task_error()
+#
+# Fetches the last exception from a task
+#
+# Used by regression tests
+#
+def get_last_task_error():
global _last_task_error_domain
global _last_task_error_reason
@@ -48,8 +59,14 @@ def _get_last_task_error():
return (d, r)
-# Called from the scheduler when an error is encountered
-def _set_last_task_error(domain, reason):
+# set_last_task_error()
+#
+# Sets the last exception of a task
+#
+# This is set by some internals to inform regression
+# tests about how things failed in a machine readable way
+#
+def set_last_task_error(domain, reason):
global _last_task_error_domain
global _last_task_error_reason
@@ -150,17 +167,20 @@ class LoadErrorReason(Enum):
# BuildStream does not support the required project format version
UNSUPPORTED_PROJECT = 7
+ # Project requires a newer version of a plugin than the one which was loaded
+ UNSUPPORTED_PLUGIN = 8
+
# A conditional expression failed to resolve
- EXPRESSION_FAILED = 8
+ EXPRESSION_FAILED = 9
# An assertion was intentionally encoded into project YAML
- USER_ASSERTION = 9
+ USER_ASSERTION = 10
# A list composition directive did not apply to any underlying list
- TRAILING_LIST_DIRECTIVE = 10
+ TRAILING_LIST_DIRECTIVE = 11
# Conflicting junctions in subprojects
- CONFLICTING_JUNCTION = 11
+ CONFLICTING_JUNCTION = 12
# LoadError
diff --git a/buildstream/_scheduler/job.py b/buildstream/_scheduler/job.py
index d4f5238c5..5d2e22646 100644
--- a/buildstream/_scheduler/job.py
+++ b/buildstream/_scheduler/job.py
@@ -30,7 +30,7 @@ import multiprocessing
from ruamel import yaml
# BuildStream toplevel imports
-from .._exceptions import BstError, _set_last_task_error
+from .._exceptions import BstError, set_last_task_error
from .._message import Message, MessageType, unconditional_messages
from ..plugin import _plugin_lookup
from .. import _yaml, _signals, utils
@@ -401,8 +401,8 @@ class Job():
# For regression tests only, save the last error domain / reason
# reported from a child task in the main process, this global state
# is currently managed in _exceptions.py
- _set_last_task_error(envelope.message['domain'],
- envelope.message['reason'])
+ set_last_task_error(envelope.message['domain'],
+ envelope.message['reason'])
elif envelope.message_type == 'result':
assert self.result is None
self.result = envelope.message
diff --git a/buildstream/_scheduler/queue.py b/buildstream/_scheduler/queue.py
index 0cea1005f..d03ce6864 100644
--- a/buildstream/_scheduler/queue.py
+++ b/buildstream/_scheduler/queue.py
@@ -28,7 +28,7 @@ import traceback
from .job import Job
# BuildStream toplevel imports
-from .._exceptions import BstError, _set_last_task_error
+from .._exceptions import BstError, set_last_task_error
from .._message import Message, MessageType
@@ -229,7 +229,7 @@ class Queue():
#
# This just allows us stronger testing capability
#
- _set_last_task_error(e.domain, e.reason)
+ set_last_task_error(e.domain, e.reason)
except Exception as e: # pylint: disable=broad-except
diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py
index 8e3df1970..521e6487f 100644
--- a/tests/testutils/runcli.py
+++ b/tests/testutils/runcli.py
@@ -26,7 +26,7 @@ from buildstream._frontend import cli as bst_cli
from buildstream import _yaml
# Special private exception accessor, for test case purposes
-from buildstream._exceptions import BstError, _get_last_exception, _get_last_task_error
+from buildstream._exceptions import BstError, get_last_exception, get_last_task_error
# Wrapper for the click.testing result
@@ -62,9 +62,9 @@ class Result():
if not isinstance(exception, SystemExit):
self.unhandled_exception = True
- self.exception = _get_last_exception()
+ self.exception = get_last_exception()
self.task_error_domain, \
- self.task_error_reason = _get_last_task_error()
+ self.task_error_reason = get_last_task_error()
else:
self.exception = None
self.task_error_domain = None