diff --git a/tests/platform-matrix.rs b/tests/platform-matrix.rs index 1f9f1cf..400e9e7 100644 --- a/tests/platform-matrix.rs +++ b/tests/platform-matrix.rs @@ -18,21 +18,22 @@ struct PlatformTest { fn read_manifest(host: &str, manifest_type: &str) -> Option { let manifest_dir = Path::new("manifests"); - // Find the most recent matching manifest - if let Ok(entries) = fs::read_dir(manifest_dir) { - for entry in entries.flatten() { - if let Ok(filename) = entry.file_name().into_string() { - if filename.contains(host) && filename.contains(manifest_type) { - if let Ok(content) = fs::read_to_string(entry.path()) { - if let Ok(json) = serde_json::from_str::(&content) { - return Some(json); - } - } - } - } - } - } - None + // Match the exact `-.json` suffix so a loose substring + // does not also grab a sibling like `…watchdog-host-status-run-manifest.json` + // (which has no `.status`). Collect all matches and pick the lexically + // greatest filename — dated `YYYY-MM-DD-` prefixes sort to "most recent" — + // so the result is deterministic regardless of `read_dir` ordering. + let suffix = format!("{}-{}.json", host, manifest_type); + let mut matches: Vec<_> = fs::read_dir(manifest_dir) + .ok()? + .flatten() + .filter_map(|entry| entry.file_name().into_string().ok().map(|n| (n, entry.path()))) + .filter(|(name, _)| name.ends_with(&suffix)) + .collect(); + matches.sort_by(|a, b| a.0.cmp(&b.0)); + let (_, path) = matches.last()?; + let content = fs::read_to_string(path).ok()?; + serde_json::from_str::(&content).ok() } fn test_deepseek_cache_probe(platform: &str, host: &str) -> PlatformTest {