Skip to content

Rust

Runner cargo test
Static graph mod, use, crate:: paths, workspace crate names, inline #[cfg(test)] tests
Recorded tier yes, with cargo-llvm-cov; file-level
Terminal window
cargo install cargo-llvm-cov
rustup component add llvm-tools-preview
trimtest record --coverage

Each integration test (tests/*.rs) and each file with inline #[cfg(test)] tests runs alone under cargo llvm-cov. Inline files filter by module path, so they run that file’s tests plus any whose module path matches. Rust has no reflection, so the gain is narrowing, not catching hidden dependencies: a test that imports a module but never runs the code that uses heavy.rs is not selected when heavy.rs changes.

Coverage cannot vouch for everything, so these stay attached to the tests that statically depend on them:

  • constants and statics, macro_rules!, and include_str! users,
  • files declaring struct, enum, trait, type, impl or derives, which have no executable line of their own,
  • proc-macro crates and every crate that depends on one,
  • everything under tests/, benches/ and examples/ (llvm-cov leaves those out).

Deleting a file that no test depends on runs the whole project, because it can still break the build (a Cargo [[bench]] target, for example).

  • Tests that use Command::new or CARGO_BIN_EXE_* start other processes, so they run on any change.
  • Doctest-only units cannot be measured; recording continues past them.