From be2e87faf4d8445367cce2d3f0bccb3f4324d4f8 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 20 Nov 2026 05:48:06 -0800 Subject: [PATCH] :art: Make the let-go tests pass clippy The pages-job test's rig needs no mut, and the shared-flush test spawns its threads and reads its clock through the video crate's runtime, as the crate's lints ask, instead of std's. --- .../reims-vgpu-video/src/vaapi/va/d3d11/tests.rs | 14 ++++++++++---- .../src/graphics/decode/surface_cache.rs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/reims-vgpu-video/src/vaapi/va/d3d11/tests.rs b/crates/reims-vgpu-video/src/vaapi/va/d3d11/tests.rs index 13db33c36..72954624c 100644 --- a/crates/reims-vgpu-video/src/vaapi/va/d3d11/tests.rs +++ b/crates/reims-vgpu-video/src/vaapi/va/d3d11/tests.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::ptr::null_mut; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::time::{Duration, Instant}; +use std::time::Duration; use crate::core::runtime::{Runtime as _, StdRuntime}; @@ -439,15 +439,21 @@ fn pairs_let_go_together_share_one_flush() { let threads: Vec<_> = (pairs.into_iter()) .map(|pair| { let returned = Arc::clone(&returned); - std::thread::spawn(move || { + StdRuntime::thread("pair-drop", move || { drop(pair); returned.fetch_add(1, Ordering::SeqCst); }) + .expect("a thread") }) .collect(); - let deadline = Instant::now() + Duration::from_secs(10); + // The tests' clock: std's, which the library does not read. + let clock = StdRuntime; + let asked = clock.now(); while draw.flushes.owed.lock().asked < 4 { - assert!(Instant::now() < deadline, "the four pairs ask for a flush"); + assert!( + clock.elapsed_since(asked) < Duration::from_secs(10), + "the four pairs ask for a flush" + ); std::thread::sleep(Duration::from_millis(1)); } std::thread::sleep(Duration::from_millis(20)); diff --git a/crates/reims-vgpu/src/graphics/decode/surface_cache.rs b/crates/reims-vgpu/src/graphics/decode/surface_cache.rs index 88428374e..ae6f0f866 100644 --- a/crates/reims-vgpu/src/graphics/decode/surface_cache.rs +++ b/crates/reims-vgpu/src/graphics/decode/surface_cache.rs @@ -10493,7 +10493,7 @@ pub(super) mod tests { /// `SURFACE_PAGES` waited about half a second for a thread #[test] fn a_pages_job_made_while_released_caches_wait_to_go_does_not_wait_for_them() { - let mut r = cached(); + let r = cached(); let cache = reims_vgpu_vulkan::core::platform::ObjId(cache_id(&r)); r.dec.let_go_worker().hold(); r.dec