From f5927f1ff7e7e37f8580043cdd2cb7a5cf3babef Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 02:58:01 -0800 Subject: [PATCH] rt store tests: the directory walk counts nothing for a file the removal takes while it lists it tests::cache::a_store_filled_past_its_cap_stays_within_it_and_moves_on panicked on the XTX leg of the matrix at e060958855 ("its metadata: NotFound"): bytes_under() walks the store's directory while the store's removal thread deletes the dead generation, so an entry read_dir listed can be gone by its metadata(). The walk now counts such an entry as nothing (NotFound only; any other error still fails), which can only count less than the directory held when the walk started, so the test's bound while a removal runs (at most 1.5 times the cap on disk) stays a sound check, and its checks after settle() are unchanged. Verified: the rt store tests and clippy of rt's targets in the check job named in the hand-over. --- crates/metal2vulkan-rt/src/tests/cache.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/metal2vulkan-rt/src/tests/cache.rs b/crates/metal2vulkan-rt/src/tests/cache.rs index c34a0f570..c2f3dfb68 100644 --- a/crates/metal2vulkan-rt/src/tests/cache.rs +++ b/crates/metal2vulkan-rt/src/tests/cache.rs @@ -6,6 +6,7 @@ use crate::cache::{frame, unframe, State, Store}; use std::fs; +use std::io::ErrorKind; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; use std::sync::Arc; @@ -33,18 +34,21 @@ impl Drop for Scratch { } } -/// The bytes of every file under `dir`; none where it is missing. +/// The bytes of every file under `dir`; none where it is missing. A file or directory the store's +/// removal thread takes while the walk lists it counts nothing: what the walk finds is never more +/// than the directory held when it started. fn bytes_under(dir: &Path) -> u64 { let Ok(entries) = fs::read_dir(dir) else { return 0; }; entries .map(|entry| { - let entry = entry.expect("an entry"); - let meta = entry.metadata().expect("its metadata"); - match meta.is_dir() { - true => bytes_under(&entry.path()), - false => meta.len(), + let meta = entry.and_then(|entry| Ok((entry.metadata()?, entry.path()))); + match meta { + Ok((meta, path)) if meta.is_dir() => bytes_under(&path), + Ok((meta, _)) => meta.len(), + Err(error) if error.kind() == ErrorKind::NotFound => 0, + Err(error) => panic!("{}: {error}", dir.display()), } }) .sum()