summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-09-21 17:58:15 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-10-27 18:17:21 +0900
commitf083c0e45996164a82978589192a395ad40d2b27 (patch)
tree654a48a7fc09a8f53cc01fded90b1413468cae22 /tests
parent80d02e3b61a69886f66aed92ae24ff49956dcb3a (diff)
downloadbuildstream-f083c0e45996164a82978589192a395ad40d2b27.tar.gz
Restore task element name / element name distinction in UI
This behavior has regressed a while back when introducing the messenger object in 0026e379 from merge request !1500. Main behavior change: - Messages in the master log always appear with the task element's element name and cache key, even if the element or plugin issuing the log line is not the primary task element. - Messages logged in the task specific log, retain the context of the element names and cache keys which are issuing the log lines. Changes include: * _message.py: Added the task element name & key members * _messenger.py: Log the element key as well if it is provided * _widget.py: Prefer the task name & key when logging, we fallback to the element name & key in case messages are being logged outside of any ongoing task (main process/context) * job.py: Unconditionally stamp messages with the task name & key Also removed some unused parameters here, clearing up an XXX comment * plugin.py: Add new `_message_kwargs` instance property, it is the responsibility of the core base class to maintain the base keyword arguments which are to be used as kwargs for Message() instances created on behalf of the issuing plugin. Use this method to construct messages in Plugin.__message() and to pass kwargs along to Messenger.timed_activity(). * element.py: Update the `_message_kwargs` when the cache key is updated * tests/frontend/logging.py: Fix test to expect the cache key in the logline * tests/frontend/artifact_log.py: Fix test to expect the cache key in the logline Fixes #1393
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/artifact_log.py8
-rw-r--r--tests/frontend/logging.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/tests/frontend/artifact_log.py b/tests/frontend/artifact_log.py
index 6ea610a25..8fd51ea2a 100644
--- a/tests/frontend/artifact_log.py
+++ b/tests/frontend/artifact_log.py
@@ -19,6 +19,7 @@
# pylint: disable=redefined-outer-name
import os
+import re
import pytest
from buildstream.testing import cli # pylint: disable=unused-import
@@ -88,9 +89,12 @@ def test_artifact_log_files(cli, datafiles):
assert os.path.exists(import_bin)
# Ensure the file contains the logs by checking for the LOG line
+ pattern = r"\[..:..:..\] LOG \[.*\] target.bst"
with open(target, "r") as f:
data = f.read()
- assert "LOG target.bst" in data
+ assert len(re.findall(pattern, data, re.MULTILINE)) > 0
+
+ pattern = r"\[..:..:..\] LOG \[.*\] import-bin.bst"
with open(import_bin, "r") as f:
data = f.read()
- assert "LOG import-bin.bst" in data
+ assert len(re.findall(pattern, data, re.MULTILINE)) > 0
diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py
index 6eb058990..a86bda577 100644
--- a/tests/frontend/logging.py
+++ b/tests/frontend/logging.py
@@ -106,5 +106,5 @@ def test_failed_build_listing(cli, datafiles):
# Note that if we mess up the 'element_name' of Messages, they won't be printed
# with the name of the relevant element, e.g. 'testfail-1.bst'. Check that
# they have the name as expected.
- pattern = r"\[..:..:..\] FAILURE testfail-.\.bst: Staged artifacts do not provide command 'sh'"
+ pattern = r"\[..:..:..\] FAILURE \[.*\] testfail-.\.bst: Staged artifacts do not provide command 'sh'"
assert len(re.findall(pattern, result.stderr, re.MULTILINE)) == 6 # each element should be matched twice.