Conventional test/support classification, not evidence that tests ran or that these files cover production behavior.
(path: &str, symbol: &str)
| 260 | /// Conventional test/support classification, not evidence that tests ran or |
| 261 | /// that these files cover production behavior. |
| 262 | pub fn test_support(path: &str, symbol: &str) -> bool { |
| 263 | let parts: Vec<_> = path.split('/').collect(); |
| 264 | let file = parts.last().copied().unwrap_or(""); |
| 265 | let stem = file.rsplit_once('.').map(|(stem, _)| stem).unwrap_or(file); |
| 266 | let scope = symbol |
| 267 | .rsplit_once('#') |
| 268 | .map(|(_, name)| name) |
| 269 | .unwrap_or(symbol) |
| 270 | .split("::") |
| 271 | .collect::<Vec<_>>(); |
| 272 | parts.iter().any(|part| { |
| 273 | matches!( |
| 274 | *part, |
| 275 | "tests" |
| 276 | | "test" |
| 277 | | "__tests__" |
| 278 | | "fixtures" |
| 279 | | "testdata" |
| 280 | | "examples" |
| 281 | | "benches" |
| 282 | | "benchmarks" |
| 283 | ) |
| 284 | }) || matches!(stem, "test" | "tests") |
| 285 | || file.starts_with("test_") |
| 286 | || file.contains(".test.") |
| 287 | || file.contains(".spec.") |
| 288 | || file.contains("_test.") |
| 289 | || scope |
| 290 | .iter() |
| 291 | .take(scope.len().saturating_sub(1)) |
| 292 | .any(|part| matches!(*part, "tests" | "test")) |
| 293 | } |
| 294 | |
| 295 | /// Stable conventional component grouping; explicit package roots are not |
| 296 | /// inferred from compiler/build configuration. |