summaryrefslogtreecommitdiff
path: root/tests/frontend/logging/plugins/logtest.py
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-10-25 16:33:17 +0900
committerJürg Billeter <j@bitron.ch>2020-10-27 10:00:51 +0100
commit70446fde40d335b6465aa53855b74eef2c0424fd (patch)
treea5b8ccbd9a9a35c0bd5da861e449396c65e051ef /tests/frontend/logging/plugins/logtest.py
parent655d6c60b982067daf09687e86fd055d11301a11 (diff)
downloadbuildstream-juerg/fix-logging-element-names.tar.gz
tests/frontend/logging.py: Test log lines for correct element names/keysjuerg/fix-logging-element-names
When printing log lines to the master log, we ensure that log lines are printed with the element name and cache key which are related to the task from which the messages are being issued. When printing log lines to task specific log lines, we prefer to print the element names and cache keys which pertain to the element from which the log line was actually issued. This new tests asserts this behavior.
Diffstat (limited to 'tests/frontend/logging/plugins/logtest.py')
-rw-r--r--tests/frontend/logging/plugins/logtest.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/frontend/logging/plugins/logtest.py b/tests/frontend/logging/plugins/logtest.py
new file mode 100644
index 000000000..0817a92d8
--- /dev/null
+++ b/tests/frontend/logging/plugins/logtest.py
@@ -0,0 +1,44 @@
+from buildstream import Element
+
+
+class LogTest(Element):
+ BST_MIN_VERSION = "2.0"
+
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+ pass
+
+ def get_unique_key(self):
+ return {}
+
+ def configure_sandbox(self, sandbox):
+ pass
+
+ def stage(self, sandbox):
+ # Here we stage the artifacts of dependencies individually without
+ # using a timed activity or suppressing the logging.
+ #
+ # This allows us to test the logging behavior when log lines are
+ # triggered by an element which is not the element being processed.
+ #
+ # * The master build log should show the element name and cache key
+ # of the task element, i.e. the element currently being built, not
+ # the element issuing the message.
+ #
+ # * In the individual task log, we expect to see the name and cache
+ # key of the element issuing messages, since the entire log file
+ # is contextual to the task, it makes more sense to provide the
+ # full context of the element issuing the log in this case.
+ #
+ for dep in self.dependencies():
+ dep.stage_artifact(sandbox)
+
+ def assemble(self, sandbox):
+ return "/"
+
+
+# Plugin entry point
+def setup():
+ return LogTest