From ede610816c242f309849ae73c973cba02254256d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 2 Sep 2026 18:12:46 -0700 Subject: [PATCH] refactor: split rust test enumeration into its own module rust_runner.py owns the #[test]/#[tokio::test] regex scan, mirroring python_runner.py's split out of the old validate_ledger.py. --- .../strategies/unit_tests/rust_runner.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/rust-python-harness/strategies/unit_tests/rust_runner.py diff --git a/tests/rust-python-harness/strategies/unit_tests/rust_runner.py b/tests/rust-python-harness/strategies/unit_tests/rust_runner.py new file mode 100644 index 00000000000..6b855adbc4b --- /dev/null +++ b/tests/rust-python-harness/strategies/unit_tests/rust_runner.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +import re +from pathlib import Path + +_RUST_TEST_PATTERN = re.compile( + r"#\[(?:test|tokio::test)\][^\n]*\n(?:[^\n]*\n)*?\s*(?:async\s+)?fn\s+(\w+)\s*\(" +) + + +def enumerate_rust_tests(repo_root: Path, relative_path: str) -> frozenset[str]: + source = (repo_root / relative_path).read_text(encoding="utf-8") + return frozenset(match.group(1) for match in _RUST_TEST_PATTERN.finditer(source))