Classify a trimmed `valgrind --version` output against the pinned CodSpeed valgrind version.
(version: String)
| 182 | /// Classify a trimmed `valgrind --version` output against the pinned CodSpeed |
| 183 | /// valgrind version. |
| 184 | fn classify_valgrind_version(version: String) -> ToolInstallStatus { |
| 185 | // Check if it's a codspeed version |
| 186 | if !version.contains(".codspeed") { |
| 187 | return ToolInstallStatus::IncorrectVersion { |
| 188 | version, |
| 189 | message: "not a CodSpeed build".to_string(), |
| 190 | }; |
| 191 | } |
| 192 | |
| 193 | // Parse the installed version |
| 194 | let Some(installed_version) = parse_valgrind_codspeed_version(&version) else { |
| 195 | return ToolInstallStatus::IncorrectVersion { |
| 196 | version, |
| 197 | message: "could not parse version".to_string(), |
| 198 | }; |
| 199 | }; |
| 200 | |
| 201 | // Legacy `.codspeed` builds (no iteration suffix) predate iteration |
| 202 | // tracking, so they count as iteration 0. |
| 203 | let installed_iteration = installed_version.codspeed_iteration.unwrap_or(0); |
| 204 | let is_version_outdated = (installed_version.semver, installed_iteration) |
| 205 | < (VALGRIND_CODSPEED_VERSION, VALGRIND_CODSPEED_ITERATION); |
| 206 | if is_version_outdated { |
| 207 | return ToolInstallStatus::IncorrectVersion { |
| 208 | version, |
| 209 | message: format!( |
| 210 | "version too old, expecting {} or higher", |
| 211 | VALGRIND_CODSPEED_VERSION_STRING.as_str() |
| 212 | ), |
| 213 | }; |
| 214 | } |
| 215 | |
| 216 | ToolInstallStatus::Installed { version } |
| 217 | } |
| 218 | |
| 219 | /// Whether a valgrind-codspeed recent enough for this runner is on `PATH`. |
| 220 | fn is_valgrind_installed() -> bool { |