ci: close the two missed cargo-mutants in src/builder.rs
Shard 0 of the nightly mutation run reported two MISSED mutants:
src/builder.rs:178 Builder::failure_retry_period -> Self
src/builder.rs:210 Builder::dht_backend -> Self
Both replaced the setter body with `Default::default()`, wiping the
receiver's accumulated state. The existing #[cfg(test)] mod tests has
one of these `<setter>_setter_stores_exact_value` pinning tests for
nearly every other Builder method, but these two were missing:
- failure_retry_period: no test exercised the setter at all.
- dht_backend: the method and its callers (build_wait_none_does_not_block
et al.) are gated `#[cfg(feature = "test-support")]`, but
cargo-mutants ran with default features only, so neither the method
nor its tests were ever compiled — the mutation survived trivially.
Fixes:
- Add `failure_retry_period_setter_stores_exact_value` matching the
pattern of the other setter tests.
- Add `dht_backend_setter_stores_value` (gated on `test-support`).
- Set `additional_cargo_args = ["--features", "test-support"]` in
.cargo/mutants.toml so cfg-gated setters are part of the mutation
surface.
Verified locally: `cargo mutants --file src/builder.rs` → 17 mutants,
16 caught, 1 unviable, 0 missed.
This commit is contained in:
2 files changed
+28
No files matched your search
@@ -7,6 +7,12 @@ test_tool = "nextest"
|
|||||||
# Async tests + crypto work takes longer under mutation load.
|
# Async tests + crypto work takes longer under mutation load.
|
||||||
timeout_multiplier = 3.0
|
timeout_multiplier = 3.0
|
||||||
|
|
||||||
|
# Enable `test-support` so cfg-gated setters (e.g. Builder::dht_backend) and
|
||||||
|
# the integration tests that exercise them are part of the mutation surface.
|
||||||
|
# Without this, dht_backend mutations always "survive" trivially because the
|
||||||
|
# method isn't compiled in.
|
||||||
|
additional_cargo_args = ["--features", "test-support"]
|
||||||
|
|
||||||
# Skip paths that either can't be meaningfully mutated or are covered by
|
# Skip paths that either can't be meaningfully mutated or are covered by
|
||||||
# other tools:
|
# other tools:
|
||||||
# - sim_impl.rs: simulator is exercised via the simulator example, not
|
# - sim_impl.rs: simulator is exercised via the simulator example, not
|
||||||
|
|||||||
@@ -470,6 +470,28 @@ mod tests {
|
|||||||
assert_eq!(Builder::default().heal_period(d).heal_period, d);
|
assert_eq!(Builder::default().heal_period(d).heal_period, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn failure_retry_period_setter_stores_exact_value() {
|
||||||
|
let d = Duration::from_millis(42);
|
||||||
|
assert_eq!(
|
||||||
|
Builder::default().failure_retry_period(d).failure_retry_period,
|
||||||
|
d
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "test-support")]
|
||||||
|
fn dht_backend_setter_stores_value() {
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::sim::InMemoryDht;
|
||||||
|
let dht = Arc::new(InMemoryDht::new());
|
||||||
|
let before = Builder::default();
|
||||||
|
let after = Builder::default().dht_backend(dht);
|
||||||
|
assert!(before.dht_backend.is_none());
|
||||||
|
assert!(after.dht_backend.is_some());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn jitter_setter_stores_exact_value() {
|
fn jitter_setter_stores_exact_value() {
|
||||||
let b = Builder::default().jitter(0.25);
|
let b = Builder::default().jitter(0.25);
|
||||||
|
|||||||
Reference in new issue
Block a user