Extract a user-friendly test name for display in summary table
(command: str | list[str])
| 838 | |
| 839 | |
| 840 | def _get_friendly_test_name(command: str | list[str]) -> str: |
| 841 | """Extract a user-friendly test name for display in summary table""" |
| 842 | if isinstance(command, list): |
| 843 | command = " ".join(command) |
| 844 | |
| 845 | # Simplify common command patterns to friendly names |
| 846 | if "cpp_test_run" in command and "ci.run_tests" in command: |
| 847 | return "unit_tests" |
| 848 | elif "meson_example_runner.py" in command: |
| 849 | # Extract specific example names from command (after the .py script) |
| 850 | tokens = command.split() |
| 851 | example_names: list[str] = [] |
| 852 | found_script = False |
| 853 | for tok in tokens: |
| 854 | # Find the script first |
| 855 | if "meson_example_runner" in tok: |
| 856 | found_script = True |
| 857 | continue |
| 858 | if not found_script: |
| 859 | continue |
| 860 | # Skip flags |
| 861 | if tok.startswith("-"): |
| 862 | continue |
| 863 | # This is likely an example name (after the script) |
| 864 | example_names.append(tok) |
| 865 | if example_names: |
| 866 | return ", ".join(example_names) |
| 867 | return "examples" |
| 868 | elif "test_example_compilation.py" in command: |
| 869 | # Show script name plus example targets, e.g. "test_example_compilation.py Luminova" |
| 870 | try: |
| 871 | import os |
| 872 | |
| 873 | tokens = command.split() |
| 874 | # Find the script token and collect following non-flag args as examples |
| 875 | for i, tok in enumerate(tokens): |
| 876 | normalized = tok.strip('"') |
| 877 | if normalized.endswith("test_example_compilation.py"): |
| 878 | script_name = os.path.basename(normalized) |
| 879 | example_parts: list[str] = [] |
| 880 | for t in tokens[i + 1 :]: |
| 881 | if t.startswith("-"): |
| 882 | break |
| 883 | example_parts.append(t.strip('"')) |
| 884 | if example_parts: |
| 885 | return f"{script_name} {' '.join(example_parts)}" |
| 886 | return script_name |
| 887 | except KeyboardInterrupt as ki: |
| 888 | handle_keyboard_interrupt(ki) |
| 889 | raise |
| 890 | except Exception: |
| 891 | # Fall back to generic extraction on any unexpected parsing issue |
| 892 | pass |
| 893 | return _extract_test_name(command) |
| 894 | elif "pytest" in command and "ci/tests" in command: |
| 895 | return "python_tests" |
| 896 | elif "pytest" in command and "ci/test_integration" in command: |
| 897 | return "integration_tests" |
no test coverage detected