Rust Testing — mmap-guard#
Crate-specific delta only. Authoritative source:
AGENTS.md+GOTCHAS.md.
Framework & commands#
- Prefer nextest:
cargo nextest run(single test:cargo nextest run <name>).
Fallback:cargo test.just testwraps this. - proptest (stable) drives property tests and runs in the normal suite. The
read_boundedproptest is a unit test insidesrc/load.rsbecause it needs the
private function;tests/prop_map_file.rscoversmap_fileround-trips. - cargo-fuzz (nightly) drives the
fuzz/targets (fuzz_read_bounded,
fuzz_map_file). The__fuzzfeature re-exportsread_boundedfor them. See
GOTCHAS.md § Fuzzing — do not use__fuzzin library code. - No async here → no
#[tokio::test].rstest/mockallare not used.
Coverage#
cargo llvm-cov; the threshold is 85% (just coverage-check), not 80%.
Gotchas#
- Test modules need
#[allow(clippy::unwrap_used, clippy::expect_used)]on the
mod testsblock (both are otherwise denied/warned). - Do not call
load("-")in unit tests — it reads real process stdin. Test the
data path withread_bounded+ aCursor, and routing withresolve_source.
See GOTCHAS.md § load / load_stdin. - Permission tests (
chmod 000→PermissionDenied) false-pass as root — relevant
underact. See GOTCHAS.md § Local CI with act.