diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-19 17:59:25 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-24 11:55:24 -0500 |
commit | 2479e8df0af7be4bfcf77f554a04767087cdc5b6 (patch) | |
tree | 6de937acdb00b7697e2436c0e59ae9a22d23afd0 | |
parent | ce01f87e3ac759b12eece4b20be1987ac0e6151c (diff) | |
download | buildstream-2479e8df0af7be4bfcf77f554a04767087cdc5b6.tar.gz |
_frontend/widget.py: Render core messages more like other messages
In order to test when core activities occur by parsing the stderr
in tests, we should make the messages conform more.
At the same time, this restores alignment of columns in core
messages with the element processing related messages.
Also, _scheduler/scheduler.py is updated to make it's activity names
conform to the (current) 5 character limit for the sake of alignment.
The tests/frontend/logging.py test gets it's regexes updated for
the log lines it checks for in stderr.
-rw-r--r-- | buildstream/_frontend/widget.py | 30 | ||||
-rw-r--r-- | buildstream/_scheduler/scheduler.py | 4 | ||||
-rw-r--r-- | tests/frontend/logging.py | 4 |
3 files changed, 17 insertions, 21 deletions
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py index 30c2e9e1a..c43856145 100644 --- a/buildstream/_frontend/widget.py +++ b/buildstream/_frontend/widget.py @@ -175,29 +175,22 @@ class TypeName(Widget): # A widget for displaying the Element name class ElementName(Widget): - def __init__(self, context, content_profile, format_profile): - super(ElementName, self).__init__(context, content_profile, format_profile) - - # Pre initialization format string, before we know the length of - # element names in the pipeline - self._fmt_string = '{: <30}' - def render(self, message): + action_name = message.action_name element_id = message.task_id or message.unique_id - if element_id is None: - return "" - - plugin = _plugin_lookup(element_id) - name = plugin._get_full_name() + if element_id is not None: + plugin = _plugin_lookup(element_id) + name = plugin._get_full_name() + name = '{: <30}'.format(name) + else: + name = 'core activity' + name = '{: <30}'.format(name) - # Sneak the action name in with the element name - action_name = message.action_name if not action_name: action_name = "Main" return self.content_profile.fmt("{: >5}".format(action_name.lower())) + \ - self.format_profile.fmt(':') + \ - self.content_profile.fmt(self._fmt_string.format(name)) + self.format_profile.fmt(':') + self.content_profile.fmt(name) # A widget for displaying the primary message text @@ -219,9 +212,12 @@ class CacheKey(Widget): def render(self, message): element_id = message.task_id or message.unique_id - if element_id is None or not self._key_length: + if not self._key_length: return "" + if element_id is None: + return ' ' * self._key_length + missing = False key = ' ' * self._key_length plugin = _plugin_lookup(element_id) diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py index eb67fed68..7f5249575 100644 --- a/buildstream/_scheduler/scheduler.py +++ b/buildstream/_scheduler/scheduler.py @@ -40,8 +40,8 @@ class SchedStatus(): # Some action names for the internal jobs we launch # -_ACTION_NAME_CLEANUP = 'cleanup' -_ACTION_NAME_CACHE_SIZE = 'cache_size' +_ACTION_NAME_CLEANUP = 'clean' +_ACTION_NAME_CACHE_SIZE = 'size' # Scheduler() diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py index a10f62cc1..3243e74bc 100644 --- a/tests/frontend/logging.py +++ b/tests/frontend/logging.py @@ -41,7 +41,7 @@ def test_default_logging(cli, tmpdir, datafiles): result = cli.run(project=project, args=['source', 'fetch', element_name]) result.assert_success() - m = re.search(r"\[\d\d:\d\d:\d\d\]\[\]\[\] SUCCESS Checking sources", result.stderr) + m = re.search(r"\[\d\d:\d\d:\d\d\]\[\s*\]\[.*\] SUCCESS Checking sources", result.stderr) assert(m is not None) @@ -77,7 +77,7 @@ def test_custom_logging(cli, tmpdir, datafiles): result = cli.run(project=project, args=['source', 'fetch', element_name]) result.assert_success() - m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,,,SUCCESS,Checking sources", result.stderr) + m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,\s*,.*,SUCCESS,Checking sources", result.stderr) assert(m is not None) |