@@ -662,6 +662,14 @@ def main(server, eventHandler, params, tf = TerminalFilter):
# terminal handler
console_handlers = [h for h in conf.config['handlers'].values() if getattr(h, 'is_console', False)]
+ if params.werror:
+ # Change the color of warning/warnonce messages to red when -W is passed
+ for h in console_handlers:
+ try:
+ h.formatter.set_warn_color_red()
+ except AttributeError:
+ pass
+
bb.utils.set_process_name("KnottyUI")
if params.options.remote_server and params.options.kill_server:
@@ -782,6 +790,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
return_value = 1
elif event.levelno == bb.msg.BBLogFormatter.WARNING:
warnings = warnings + 1
+ if params.werror:
+ return_value = 1
if event.taskpid != 0:
# For "normal" logging conditions, don't show note logs from tasks
@@ -1054,6 +1064,10 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if return_value and errors:
summary += pluralise("\nSummary: There was %s ERROR message, returning a non-zero exit code.",
"\nSummary: There were %s ERROR messages, returning a non-zero exit code.", errors)
+
+ if params.werror and warnings:
+ summary += "\nSummary: Warnings were treated as errors (-W)."
+
if summary and params.options.quiet == 0:
print(summary)
When -W is passed, modify the handlers to show warnings in red and set the return value to 1. Add a summary line informing the user that the -W option was used as it might not be obvious when looking at the bottom the end of the console log. Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> --- lib/bb/ui/knotty.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)