use std::path::Path;
pub fn is_test_path(path: &Path) -> bool {
const TEST_DIRS: &[&str] = &["tests", "test", "__tests__", "__mocks__", "spec", "specs"];
let has_test_segment = path.components().any(|c| {
c.as_os_str()
.to_str()
.is_some_and(|s| TEST_DIRS.contains(&s))
});
if has_test_segment {
return true;
}
if let Some(stem) = path.file_stem().and_then(|s| s.to_str())
&& (stem.starts_with("test_")
|| stem.ends_with("_test")
|| stem.ends_with(".test")
|| stem.ends_with(".spec")
|| stem.ends_with("_spec"))
{
return true;
}
false
}