Skip to content

Commit 46c1060

Browse files
committed
Fix return code normalization to only apply to system header errors
Only normalize exit code 1 to 0 when: 1. System header errors were detected and filtered 2. Result is empty and expected is also empty This preserves correct return codes for tests with actual errors (err.c).
1 parent c8bcd4e commit 46c1060

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/test_hooks.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,12 @@ def run_shell_cmd(cmd_name, files, args, _, target_output, target_retcode):
510510
if line or i == 0: # Keep empty lines except trailing ones
511511
filtered_lines.append(line)
512512
filtered_actual = b"\n".join(filtered_lines)
513-
# If we filtered warnings/errors and got exit code 1, normalize to 0 if output matches expected
514-
if filtered_actual != actual and sp_child.returncode == 1:
515-
# clang-tidy returns 1 when warnings/errors are generated, but if we filtered them
516-
# and the output is now empty or matches expected, treat as success
517-
if filtered_actual.strip() == b"" or filtered_actual.strip() == target_output.strip():
513+
# If we filtered system header warnings/errors and got exit code 1, normalize to 0
514+
# only if the expected output is also empty (indicating a test that should pass)
515+
if filtered_actual != actual and sp_child.returncode == 1 and in_system_header_error:
516+
# Only normalize return code if we filtered system header errors
517+
# and the result is now empty (matching expected empty output)
518+
if filtered_actual.strip() == b"" and target_output.strip() == b"":
518519
sp_child = sp.CompletedProcess(
519520
sp_child.args, 0, sp_child.stdout, sp_child.stderr
520521
)

0 commit comments

Comments
 (0)