Run tests using Meson. Args: build_dir: Meson build directory test_name: Specific test to run (None = all) verbose: Enable verbose test output exclude_suites: Optional list of test suites to exclude (e.g., ['examples']) Returns: MesonTestResult
(
build_dir: Path,
test_name: Optional[str] = None,
verbose: bool = False,
exclude_suites: Optional[list[str]] = None,
)
| 58 | |
| 59 | |
| 60 | def run_meson_test( |
| 61 | build_dir: Path, |
| 62 | test_name: Optional[str] = None, |
| 63 | verbose: bool = False, |
| 64 | exclude_suites: Optional[list[str]] = None, |
| 65 | ) -> MesonTestResult: |
| 66 | """ |
| 67 | Run tests using Meson. |
| 68 | |
| 69 | Args: |
| 70 | build_dir: Meson build directory |
| 71 | test_name: Specific test to run (None = all) |
| 72 | verbose: Enable verbose test output |
| 73 | exclude_suites: Optional list of test suites to exclude (e.g., ['examples']) |
| 74 | |
| 75 | Returns: |
| 76 | MesonTestResult with success status, duration, and test counts |
| 77 | """ |
| 78 | cmd = [ |
| 79 | get_meson_executable(), |
| 80 | "test", |
| 81 | "-C", |
| 82 | str(build_dir), |
| 83 | "--print-errorlogs", |
| 84 | ] |
| 85 | |
| 86 | if verbose: |
| 87 | cmd.append("-v") |
| 88 | |
| 89 | if test_name: |
| 90 | cmd.append(test_name) |
| 91 | |
| 92 | # Add --no-suite flags to exclude specified suites |
| 93 | if exclude_suites: |
| 94 | for suite in exclude_suites: |
| 95 | cmd.extend(["--no-suite", suite]) |
| 96 | print_banner("Test", "▶️", verbose=verbose) |
| 97 | print(f"Running: {test_name}") |
| 98 | else: |
| 99 | print_banner("Test", "▶️", verbose=verbose) |
| 100 | print("Running all tests...") |
| 101 | |
| 102 | start_time = time.time() |
| 103 | num_passed = 0 |
| 104 | num_failed = 0 |
| 105 | num_run = 0 |
| 106 | expected_total = 0 # Track Meson's expected total from output |
| 107 | |
| 108 | try: |
| 109 | # Use RunningProcess for streaming output |
| 110 | # Inherit environment to ensure compiler wrappers are available |
| 111 | proc = RunningProcess( |
| 112 | cmd, |
| 113 | timeout=600, # 10 minute timeout for tests |
| 114 | auto_run=True, |
| 115 | check=False, # We'll check returncode manually |
| 116 | env=None, # Pass current environment with wrapper paths |
| 117 | output_formatter=TimestampFormatter(), |
no test coverage detected