mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +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",
|
||||
style="gray",
|
||||
)
|
||||
# Skip 'cargo test' boilerplate at the beginning:
|
||||
lines = output.stdout.splitlines()
|
||||
start_index = 0
|
||||
for i, line in enumerate(lines):
|
||||
if f"{test_name} stdout" in line:
|
||||
start_index = i
|
||||
break
|
||||
self._print_trimmed_cargo_test_output(
|
||||
output.stdout + output.stderr, test_name
|
||||
)
|
||||
|
||||
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
|
||||
def _print_trimmed_cargo_test_output(self, output: str, test_name: str) -> None:
|
||||
# Skip 'cargo test' boilerplate at the beginning:
|
||||
lines = output.splitlines()
|
||||
start_index = 0
|
||||
for i, line in enumerate(lines):
|
||||
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:
|
||||
self._recompile_tests("Compiling tests...", message_on_success=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue