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 |
Recording
Section titled “Recording”cargo install cargo-llvm-covrustup component add llvm-tools-previewtrimtest record --coverageEach 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.
What stays attached
Section titled “What stays attached”Coverage cannot vouch for everything, so these stay attached to the tests that statically depend on them:
- constants and statics,
macro_rules!, andinclude_str!users, - files declaring
struct,enum,trait,type,implor derives, which have no executable line of their own, - proc-macro crates and every crate that depends on one,
- everything under
tests/,benches/andexamples/(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).
Things to know
Section titled “Things to know”- Tests that use
Command::neworCARGO_BIN_EXE_*start other processes, so they run on any change. - Doctest-only units cannot be measured; recording continues past them.