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)
| 110 | /// - `valgrind-3.25.1.codspeed2` (with iteration) |
| 111 | /// - same forms without the `valgrind-` prefix |
| 112 | fn parse_valgrind_codspeed_version(version_str: &str) -> Option<ValgrindVersion> { |
| 113 | let stripped = version_str |
| 114 | .trim() |
| 115 | .strip_prefix("valgrind-") |
| 116 | .unwrap_or(version_str.trim()); |
| 117 | |
| 118 | let (semver_part, iteration_part) = stripped.split_once(".codspeed")?; |
| 119 | let semver = Version::parse(semver_part).ok()?; |
| 120 | |
| 121 | let codspeed_iteration = if iteration_part.is_empty() { |
| 122 | None |
| 123 | } else { |
| 124 | Some(iteration_part.parse::<u32>().ok()?) |
| 125 | }; |
| 126 | |
| 127 | Some(ValgrindVersion { |
| 128 | semver, |
| 129 | codspeed_iteration, |
| 130 | }) |
| 131 | } |
| 132 | |
| 133 | const TOOL_NAME: &str = "valgrind"; |
| 134 |