Commit Graph

1 Commits

Author SHA1 Message Date
Fernando Lins
f76fcec48f feat: add Rust test coverage (#4842)
## Linked issue

Closes #4839

## Summary / motivation

Adds `cargo-llvm-cov`-based test coverage for the full Rust workspace.
Introduces `just test-rust --coverage` and `just test-rust --coverage
--html`, and wires Rust into the `just test --coverage` umbrella.

`cargo-llvm-cov` is installed on demand into `out/bin/` to avoid
polluting the global cargo install. The `llvm-tools-preview` rustup
component is now installed in CI so the tool can instrument binaries.

## How to test (required)

```sh
# Existing behavior unchanged
just test-rust

# Terminal summary
just test-rust --coverage

# Terminal summary + HTML report under out/coverage/rust/html/
just test-rust --coverage --html

# Umbrella (Rust + Python)
just test --coverage
just test --coverage --html
```

Note: first run of `--coverage` will install `cargo-llvm-cov` into
`out/bin/` (~30s). Subsequent runs skip the install step.

### Checklist

- [x] I ran `./ninja check` or an equivalent relevant check locally.

### Details

- `cargo-llvm-cov` pinned at `0.8.4`, installed into `out/bin/` via
`cargo install --root out`.
- `--workspace --locked` measures all crates and respects the lockfile.
- `llvm-tools-preview` added to `setup-anki` action so CI can instrument
Rust binaries.
- Coverage runs are slower than plain `just test-rust` because
`cargo-llvm-cov` rebuilds with instrumentation — this is expected.

## Before / after behavior

Before: no `just test-rust`, no Rust coverage support.

After: `just test-rust` runs Rust tests via ninja; `just test-rust
--coverage` runs them with `cargo-llvm-cov`

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2026-05-18 11:38:37 -03:00