Skip to content

Commit bb06df0

Browse files
committed
Handle combined warnings and errors pattern in clang-tidy output
macOS clang-tidy can output '148 warnings and 1 error generated.' when both warnings (from system headers) and errors (from test file) occur. Filter out the warnings part while preserving the error count.
1 parent 53e9046 commit bb06df0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_hooks.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,15 @@ def run_shell_cmd(cmd_name, files, args, _, target_output, target_retcode):
464464
actual = re.sub(rb"[\d,]+ warnings and ", b"", actual)
465465
# Filter out "X warnings generated." from clang-tidy (macOS with SDK configured)
466466
if cmd_name == "clang-tidy":
467-
# Filter warnings count and track if we filtered it
467+
# Filter warnings/errors count and track if we filtered it
468+
# Patterns: "X warnings generated." or "X warnings and Y error(s) generated."
469+
before_filter = actual
468470
filtered_actual = re.sub(rb"\d+ warnings? generated\.\n", b"", actual)
469-
filtered_warnings_count = (filtered_actual != actual)
471+
# Also filter combined pattern like "148 warnings and 1 error generated."
472+
filtered_actual = re.sub(rb"\d+ warnings? and \d+ errors? generated\.\n",
473+
lambda m: re.sub(rb"\d+ warnings? and ", b"", m.group(0)),
474+
filtered_actual)
475+
filtered_warnings_count = (filtered_actual != before_filter)
470476
# Filter errors from macOS SDK system headers
471477
lines = filtered_actual.split(b"\n")
472478
filtered_lines = []

0 commit comments

Comments
 (0)