diff --git a/src/becwright/engine.py b/src/becwright/engine.py index 230ea1a..7c85adb 100644 --- a/src/becwright/engine.py +++ b/src/becwright/engine.py @@ -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) diff --git a/tests/test_engine_integration.py b/tests/test_engine_integration.py index aa7b143..ee21d4c 100644 --- a/tests/test_engine_integration.py +++ b/tests/test_engine_integration.py @@ -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 +