mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-17 13:58:37 +00:00
[red-knot] Fix possible TOCTOU mistake in mdtest runner (#15673)
## Summary Somehow, I managed to crash the `mdtest` runner today. I struggled to reproduce this again to see if it's actually fixed (even with an artificial `sleep` between the two `cargo test` invocations), but the original backtrace clearly showed that this is where the problem originated from. And it seems like a clear TOCTOU problem.
This commit is contained in:
parent
13e7afca42
commit
3235cd8019
1 changed files with 7 additions and 1 deletions
|
@ -61,7 +61,13 @@ class MDTestRunner:
|
|||
return False
|
||||
|
||||
# Run it again with 'json' format to find the mdtest executable:
|
||||
json_output = self._run_cargo_test(message_format="json")
|
||||
try:
|
||||
json_output = self._run_cargo_test(message_format="json")
|
||||
except subprocess.CalledProcessError as _:
|
||||
# `cargo test` can still fail if something changed in between the two runs.
|
||||
# Here we don't have a human-readable output, so just show a generic message:
|
||||
self.console.print("[red]Error[/red]: Failed to compile tests")
|
||||
return False
|
||||
|
||||
if json_output:
|
||||
self._get_executable_path_from_json(json_output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue