mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
[red-knot] mdtest runner: include stderr for crashing tests (#15644)
## Summary Test executables usually write failure messages (including panics) to stdout, but I just managed to make a mdtest crash with ``` thread 'mdtest__unary_not' has overflowed its stack fatal runtime error: stack overflow ``` which is printed to stderr. This test simply appends stderr to stdout (`stderr=subprocess.STDOUT` can not be used with `capture_output`) ## Test Plan Make sure that the error message is now visible in the output of `uv -q run crates/red_knot_python_semantic/mdtest.py`
This commit is contained in:
parent
067c6de465
commit
13a6b5600b
1 changed files with 19 additions and 14 deletions
|
@ -125,22 +125,27 @@ class MDTestRunner:
|
||||||
f"Test for [bold red]{markdown_file}[/bold red] failed",
|
f"Test for [bold red]{markdown_file}[/bold red] failed",
|
||||||
style="gray",
|
style="gray",
|
||||||
)
|
)
|
||||||
# Skip 'cargo test' boilerplate at the beginning:
|
self._print_trimmed_cargo_test_output(
|
||||||
lines = output.stdout.splitlines()
|
output.stdout + output.stderr, test_name
|
||||||
start_index = 0
|
)
|
||||||
for i, line in enumerate(lines):
|
|
||||||
if f"{test_name} stdout" in line:
|
|
||||||
start_index = i
|
|
||||||
break
|
|
||||||
|
|
||||||
for line in lines[start_index + 1 :]:
|
def _print_trimmed_cargo_test_output(self, output: str, test_name: str) -> None:
|
||||||
if "MDTEST_TEST_FILTER" in line:
|
# Skip 'cargo test' boilerplate at the beginning:
|
||||||
continue
|
lines = output.splitlines()
|
||||||
if line.strip() == "-" * 50:
|
start_index = 0
|
||||||
# Skip 'cargo test' boilerplate at the end
|
for i, line in enumerate(lines):
|
||||||
break
|
if f"{test_name} stdout" in line:
|
||||||
|
start_index = i
|
||||||
|
break
|
||||||
|
|
||||||
print(line)
|
for line in lines[start_index + 1 :]:
|
||||||
|
if "MDTEST_TEST_FILTER" in line:
|
||||||
|
continue
|
||||||
|
if line.strip() == "-" * 50:
|
||||||
|
# Skip 'cargo test' boilerplate at the end
|
||||||
|
break
|
||||||
|
|
||||||
|
print(line)
|
||||||
|
|
||||||
def watch(self) -> Never:
|
def watch(self) -> Never:
|
||||||
self._recompile_tests("Compiling tests...", message_on_success=False)
|
self._recompile_tests("Compiling tests...", message_on_success=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue