weather: allow intentional clippy fixtures in om tests
- Commit
4164556873c94ff56f2e15df75e1934e6b13b887- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 21:52 UTC (4 days ago)
- Parents
79ef985
The full-workspace clippy run (cargo clippy --locked --workspace --all-targets) failed to compile weather_om's test target: clippy::reversed_empty_ranges is deny-by-default and rejected the inverted ranges in read_f32_inverted_range_is_err_not_panic, and clippy::single_range_in_vec_init warned on the one-range slices passed to read_f32 in two error-path tests. Both are the fixture under test, not code to rewrite: read_f32 takes &[Range<u64>] and must reject inverted and wrong-arity windows with Err instead of iterating or panicking, and the lint's suggested collect::<Vec<u64>>() replacement does not typecheck against that API. Add per-test #[allow] attributes with comments stating why, leaving the assertions byte-identical. No crate-level allows. The two too_many_arguments warnings on private helpers in lib.rs are left standing: grouping their parameters is an API redesign, not a mechanical fix. Verified: cargo test -p weather_om (77 passed), cargo fmt --check -p weather_om clean. The clippy test-target error is gone; the two lib.rs warnings remain by design.
Diff
weather/src/main/rust/src/om_tests.rs
diff --git a/weather/src/main/rust/src/om_tests.rs b/weather/src/main/rust/src/om_tests.rsindex 097dbe3b5d..11949d8f16 100644--- a/weather/src/main/rust/src/om_tests.rs+++ b/weather/src/main/rust/src/om_tests.rs@@ -52,12 +52,17 @@ fn read_f32_exact_values_other_var() { let u = r.get_child_by_name("wind_u_component_10m").unwrap(); assert_eq!(u.read_f32(&[0..2, 0..2]).unwrap(), vec![3.0, 0.0, 6.0, 0.0]); }+// `read_f32` takes `&[Range<u64>]`; a one-range slice is the API, not a+// `Vec` init, so `single_range_in_vec_init` is a false positive here.+#[allow(clippy::single_range_in_vec_init)] #[test] fn read_f32_on_scalar_is_err() { let r = reader(sample()); let s = r.get_child_by_name("scale").unwrap(); assert!(s.read_f32(&[0..1]).is_err()); }+// See `read_f32_on_scalar_is_err`: one-range slices are the `read_f32` API.+#[allow(clippy::single_range_in_vec_init)] #[test] fn read_f32_out_of_bounds_is_err() { let r = reader(sample());@@ -139,6 +144,9 @@ fn nan_values_round_trip() { assert!(out[1].is_nan()); assert_eq!(out[2..], [3.0, 4.0]); }+// Inverted ranges are the fixture under test: `read_f32` must reject them+// with `Err`, not iterate or panic, so `reversed_empty_ranges` is intended.+#[allow(clippy::reversed_empty_ranges)] #[test] fn read_f32_inverted_range_is_err_not_panic() { let r = reader(sample());