@@ -1520,18 +1520,29 @@ class LoreMessage:
topdir = git_get_toplevel()
mycmd = os.path.basename(cmdargs[0])
ecode, out, err = _run_command(cmdargs, stdin=bdata, rundir=topdir)
+ report = list()
+
out = out.strip()
out_lines = out.decode(errors='replace').split('\n') if out else list()
- report = list()
- if out_lines:
- 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
- if line.startswith('-:'):
- line = line[2:]
- report.append((flag, f'{mycmd}: {line}'))
- else:
- report.append(('success', f'{mycmd}: passed all checks'))
+ 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
+ if line.startswith('-:'):
+ line = line[2:]
+ report.append((flag, f'{mycmd}: {line}'))
+
+ err = err.strip()
+ err_lines = err.decode(errors='replace').split('\n') if err else list()
+ for line in err_lines:
+ if line.startswith('-:'):
+ line = line[2:]
+ report.append(('fail', f'{mycmd}: {line}'))
+
+ if (not out_lines) and (not err_lines):
+ if ecode:
+ report.append(('fail', f'{mycmd}: Exited with error code {ecode}'))
+ else:
+ report.append(('success', f'{mycmd}: passed all checks'))
save_cache(report, cacheid, suffix='checks', is_json=True)
return report
The ecode and stderr from check commands gets silently ignored. This means if the check failed for some unrelated reason, it will appear as a success to the patch author. Treat all output from stderr as failure lines, as it's expected normal findings would go to stdout. Treat an error from the ecode as meaningful only if stdout and stderr were blank, as checkpatch normally returns an ecode error if there are any findings. Signed-off-by: Brandon Maier <brandon.maier@collins.com> --- src/b4/__init__.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) --- base-commit: 131835a44c63511e2def9d7adc680754b7ea502c change-id: 20240626-report-check-cmd-stderr-84b1cb28aa40 Best regards,