diff mbox series

[b4,3/3] Differentiate between checkcmd error and checkmd patch fail

Message ID 20240815-extend-checkpatch-v1-3-ab7f654be699@linaro.org (mailing list archive)
State Changes Requested
Headers show
Series Extend checkpatch.pl compatibilities | expand

Commit Message

Manos Pitsidianakis Aug. 15, 2024, 1:36 p.m. UTC
If the check command fails for a non-patch related reason, if for
example the b4 config includes a wrong flag for the checkpatch command
or has an invalid command in general, it is not possible to disambiguate
whether the failure is with the patch or with the checkpatch invocation
instead.

This commit checks the stderr output of the check command, and prints it
if it's not empty. Furthermore, it does not cache the output since the
check was never essentially performed.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
 src/b4/__init__.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 2b1a058..2da375c 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -1522,8 +1522,13 @@  class LoreMessage:
         ecode, out, err = _run_command(cmdargs, stdin=bdata, rundir=topdir)
         out = out.strip()
         out_lines = out.decode(errors='replace').split('\n') if out else list()
+        commanderror = False
         report = list()
         if out_lines:
+            if err and ecode > 0:
+                logger.critical('CRITICAL: Running %s failed:', ' '.join(cmdargs))
+                logger.critical(err.decode(errors='ignore'))
+                commanderror |= True
             for line in out_lines:
                 flag = 'fail' if 'ERROR:' in line else 'warning'
                 # Remove '-:' from the start of the line, because it's never useful
@@ -1533,7 +1538,8 @@  class LoreMessage:
         else:
             report.append(('success', f'{mycmd}: passed all checks'))
 
-        save_cache(report, cacheid, suffix='checks', is_json=True)
+        if not commanderror:
+            save_cache(report, cacheid, suffix='checks', is_json=True)
         return report
 
     def load_local_ci_status(self, checkcmds: List[List[str]]) -> None: