Parse a valgrind version string and extract the upstream semver plus the optional CodSpeed iteration number. Accepted formats: - `valgrind-3.25.1.codspeed` (legacy, no iteration) - `valgrind-3.25.1.codspeed2` (with iteration) - same forms without the `valgrind-` prefix
(version_str: &str)
| 67 | /// - `valgrind-3.25.1.codspeed2` (with iteration) |
| 68 | /// - same forms without the `valgrind-` prefix |
| 69 | fn parse_valgrind_codspeed_version(version_str: &str) -> Option<ValgrindVersion> { |
| 70 | let stripped = version_str |
| 71 | .trim() |
| 72 | .strip_prefix("valgrind-") |
| 73 | .unwrap_or(version_str.trim()); |
| 74 | |
| 75 | let (semver_part, iteration_part) = stripped.split_once(".codspeed")?; |
| 76 | let semver = Version::parse(semver_part).ok()?; |
| 77 | |
| 78 | let codspeed_iteration = if iteration_part.is_empty() { |
| 79 | None |
| 80 | } else { |
| 81 | Some(iteration_part.parse::<u32>().ok()?) |
| 82 | }; |
| 83 | |
| 84 | Some(ValgrindVersion { |
| 85 | semver, |
| 86 | codspeed_iteration, |
| 87 | }) |
| 88 | } |
| 89 | |
| 90 | const TOOL_NAME: &str = "valgrind"; |
| 91 |