Extract TEST_CASE names from a test file.
(file_path: Path, search_pattern: str = "")
| 717 | |
| 718 | |
| 719 | def extract_test_cases(file_path: Path, search_pattern: str = "") -> list[str]: |
| 720 | """Extract TEST_CASE names from a test file.""" |
| 721 | test_cases: list[str] = [] |
| 722 | |
| 723 | try: |
| 724 | with open(file_path, "r", encoding="utf-8") as f: |
| 725 | content = f.read() |
| 726 | |
| 727 | # Find TEST_CASE macros using regex |
| 728 | pattern = r'TEST_CASE\s*\(\s*"([^"]+)"' |
| 729 | matches = re.findall(pattern, content) |
| 730 | |
| 731 | for match in matches: |
| 732 | if not search_pattern or search_pattern.lower() in match.lower(): |
| 733 | test_cases.append(match) |
| 734 | |
| 735 | except Exception: |
| 736 | # Silently skip files that can't be read |
| 737 | pass |
| 738 | |
| 739 | return test_cases |
| 740 | |
| 741 | |
| 742 | async def test_instructions( |
no test coverage detected