Skip to content

fix: capture both stdout and stderr in check execution#98

Merged
DataDave-Dev merged 4 commits into
DataDave-Dev:mainfrom
YasserYG8:fix/engine-stderr-capture
Jul 8, 2026
Merged

fix: capture both stdout and stderr in check execution#98
DataDave-Dev merged 4 commits into
DataDave-Dev:mainfrom
YasserYG8:fix/engine-stderr-capture

Conversation

@YasserYG8

@YasserYG8 YasserYG8 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in becwright's execution engine where error details written to stderr were silently discarded if the check command also output any text to stdout.

It replaces the short-circuiting logical or capture with a concatenation of both stdout and stderr outputs, ensuring developers see the complete traceback and diagnostic error logs from failing checks.

Fixes #97

Key Changes

1. Engine Capture Fix

  • src/becwright/engine.py: Refactored the output retrieval in _run_check() to compile both stdout and stderr outputs into a single, newline-joined result string.

2. Testing

  • tests/test_engine_integration.py: Added test_evaluate_captures_both_stdout_and_stderr which mocks a failing command printing to both channels and verifies that both outputs are correctly reported.

Verification Results

The test suite runs fully green:

collected 294 items
======================= 294 passed in 112.00s (0:01:52) =======================

Summary by CodeRabbit

  • Bug Fixes

    • Improved rule-check output so both standard output and error messages are included when a check runs.
    • Preserved existing pass/fail behavior and timeout handling.
  • Tests

    • Added coverage to verify rule checks capture both output streams in the reported result.

@YasserYG8 YasserYG8 requested a review from DataDave-Dev as a code owner July 8, 2026 16:38
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e6073e7-bd4d-42d3-ada2-f0f50d5e45c2

📥 Commits

Reviewing files that changed from the base of the PR and between d14b9b5 and e6ba396.

📒 Files selected for processing (2)
  • src/becwright/engine.py
  • tests/test_engine_integration.py

📝 Walkthrough

Walkthrough

The _run_check function in the engine module was updated to combine both stdout and stderr output from rule check subprocesses, joining them with newlines when both are present, rather than discarding stderr when stdout exists. A corresponding integration test was added.

Changes

Combined stdout/stderr output fix

Layer / File(s) Summary
Combine stdout and stderr in check output
src/becwright/engine.py, tests/test_engine_integration.py
_run_check now strips and joins both proc.stdout and proc.stderr with newlines instead of discarding stderr when stdout is non-empty; a new integration test verifies both streams appear in per_rule[0].output for a failing rule.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preserving both stdout and stderr during check execution.
Description check ✅ Passed The description covers the bug, the fix, related issue, key changes, and test verification, though it omits the template's checklist.
Linked Issues check ✅ Passed The code change and test directly satisfy #97 by preserving both stdout and stderr in _run_check output.
Out of Scope Changes check ✅ Passed The PR stays focused on the output-capture fix and its test, with no apparent unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DataDave-Dev DataDave-Dev merged commit 8c9c652 into DataDave-Dev:main Jul 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: preserve stderr output when stdout is not empty during check runs

2 participants