litellm/tests/rust-python-harness/strategies/unit_tests/rust_runner.py
Ishaan Jaff ede610816c
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.
2026-09-02 18:12:46 -07:00

13 lines
431 B
Python

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))