From 312d958a9191c21414d0f6ee86254dffa8525573 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Wed, 13 May 2026 10:23:47 -0600 Subject: [PATCH] ci: close the two missed cargo-mutants in src/builder.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_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. --- .cargo/mutants.toml | 6 ++++++ src/builder.rs | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml index 03c3591..981cbee 100644 --- a/.cargo/mutants.toml +++ b/.cargo/mutants.toml @@ -7,6 +7,12 @@ test_tool = "nextest" # Async tests + crypto work takes longer under mutation load. 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 # other tools: # - sim_impl.rs: simulator is exercised via the simulator example, not diff --git a/src/builder.rs b/src/builder.rs index b369e09..0dd5589 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -470,6 +470,28 @@ mod tests { 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] fn jitter_setter_stores_exact_value() { let b = Builder::default().jitter(0.25);