Hmbown/CodeWhale · error · PersistenceBacklogMeasurementError

exact library measurement test {TEST_NAME} ran zero tests

Error message

exact library measurement test {TEST_NAME} ran zero tests

What it means

measure-persistence-backlog.py runs exactly one ignored cargo test ('cargo test --locked -p codewhale-tui --lib <TEST_NAME> -- --exact --ignored --test-threads=1') and scans combined stdout/stderr for libtest's 'running 0 tests'. Zero executed tests means the receipt cannot be trusted, so the script aborts before reading it. Typical causes: the test was renamed or moved, its #[ignore] attribute was removed (so the --ignored filter excludes it), or it is feature/cfg-gated off.

Source

Thrown at scripts/measure-persistence-backlog.py:64

def run_measurement(receipt_path: Path, env: dict[str, str]) -> dict:
    result = subprocess.run(
        measurement_command(),
        cwd=ROOT,
        env=env,
        text=True,
        capture_output=True,
        check=False,
    )
    sys.stderr.write(result.stderr)
    if result.returncode != 0:
        sys.stdout.write(result.stdout)
        result.check_returncode()

    combined = "\n".join(result.stdout.splitlines() + result.stderr.splitlines())
    if re.search(r"\brunning\s+0\s+tests?\b", combined):
        sys.stdout.write(result.stdout)
        raise PersistenceBacklogMeasurementError(
            f"exact library measurement test {TEST_NAME} ran zero tests"
        )
    try:
        return json.loads(receipt_path.read_text(encoding="utf-8"))
    except (OSError, json.JSONDecodeError) as error:
        raise PersistenceBacklogMeasurementError(
            f"exact library measurement test {TEST_NAME} emitted no valid receipt: {error}"
        ) from error


def main() -> int:
    source_sha = subprocess.run(
        ["git", "rev-parse", "HEAD"],
        cwd=ROOT,
        text=True,
        capture_output=True,
        check=True,
    ).stdout.strip()

View on GitHub (pinned to 8880682c63)

Solutions

  1. Keep the test at tui::persistence_actor::backlog_measurement_tests::write_paused_persistence_backlog_measurement_receipt with #[ignore] - the script opts in via --ignored
  2. If renamed, update TEST_NAME in scripts/measure-persistence-backlog.py:21-24 in the same commit
  3. Reproduce the selection and confirm 'running 1 test': 'cargo test --locked -p codewhale-tui --lib <TEST_NAME> -- --exact --ignored --test-threads=1'

Example fix

// before (crates/tui/src/persistence_actor.rs)
#[test]
fn write_paused_persistence_backlog_measurement_receipt() { /* #[ignore] removed */ }

// after
#[test]
#[ignore = "measurement: run via scripts/measure-persistence-backlog.py"]
fn write_paused_persistence_backlog_measurement_receipt() { /* ... */ }
Defensive patterns

Strategy: validation

Validate before calling

import re, subprocess
out = subprocess.run(["cargo", "test", "--locked", "-p", "codewhale-tui", "--lib", TEST_NAME, "--", "--exact", "--ignored", "--list"], capture_output=True, text=True)
assert TEST_NAME.split("::")[-1] in out.stdout, "measurement test not selected - renamed or un-ignored?"

Type guard

def is_backlog_measurement_error(exc: BaseException) -> bool:
    return isinstance(exc, RuntimeError) and type(exc).__name__ == "PersistenceBacklogMeasurementError"

Try / catch

try:
    receipt = run_measurement(receipt_path, env)
except PersistenceBacklogMeasurementError as error:
    sys.stderr.write(f"invalid persistence backlog receipt: {error}\n")
    return 1

Prevention

When it happens

Trigger: TEST_NAME 'tui::persistence_actor::backlog_measurement_tests::write_paused_persistence_backlog_measurement_receipt' no longer matches a test path (module renamed persistence_actor -> persistence); #[ignore] removed so --ignored filters the test out; backlog_measurement_tests moved behind a non-default cfg.

Common situations: Renaming tui::persistence_actor during refactors; well-meaning removal of #[ignore] to run it with the suite; feature reorganization in codewhale-tui.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/8d1106dfac7f3041. Report an issue: GitHub.