Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/becwright/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def _run_check(rule: Rule, stdin: str, root: Path) -> RuleResult:
rule=rule, passed=False,
output=f"check timed out after {_check_timeout():g}s (its command hung)",
)
output = proc.stdout.strip() or proc.stderr.strip()
outputs = [proc.stdout.strip(), proc.stderr.strip()]
output = "\n".join(o for o in outputs if o).strip()
return RuleResult(rule=rule, passed=proc.returncode == 0, output=output)


Expand Down
11 changes: 11 additions & 0 deletions tests/test_engine_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,14 @@ def test_evaluate_times_out_a_hung_check(tmp_path, monkeypatch):
assert result.per_rule[0].passed is False
assert "timed out" in result.per_rule[0].output
assert result.had_blocking is True


def test_evaluate_captures_both_stdout_and_stderr(tmp_path):
(tmp_path / "a.py").write_text("x = 1\n", encoding="utf-8")
check = f'"{sys.executable}" -c "import sys; print(\'out_msg\'); print(\'err_msg\', file=sys.stderr); sys.exit(1)"'
rule = Rule(id="both", paths=("**/*.py",), check=check, severity="blocking")
result = evaluate([rule], ["a.py"], tmp_path)
assert result.per_rule[0].passed is False
assert "out_msg" in result.per_rule[0].output
assert "err_msg" in result.per_rule[0].output

Loading