//! The stub guard (review 010 action 3): no `*:not_implemented` path //! may exist in `src/`. A handler that registers successfully and //! returns an error of this form on every invocation is a bug, not a //! documented limitation — shipping one is a hard failure per the //! repo ruling (reviews 010/011; four stubs shipped across nine //! published versions before this guard existed). #[test] fn source_tree_has_no_not_implemented_path() { let manifest = env!("CARGO_MANIFEST_DIR"); let src = std::path::Path::new(manifest).join("src"); let mut offenders = Vec::new(); walk(&src, &mut offenders); assert!( offenders.is_empty(), "no `not_implemented` string may appear in src/ — a registered surface \ that always fails is the stub class (review 010 S-01..S-04); offended \ by: {offenders:?}" ); } fn walk(dir: &std::path::Path, offenders: &mut Vec) { let entries = match std::fs::read_dir(dir) { Ok(entries) => entries, Err(_) => return, }; for entry in entries.flatten() { let path = entry.path(); if path.is_dir() { walk(&path, offenders); } else if path.extension().is_some_and(|e| e == "rs") { let contents = match std::fs::read_to_string(&path) { Ok(c) => c, Err(_) => continue, }; for (line_no, line) in contents.lines().enumerate() { if line.contains("not_implemented") { offenders.push(format!( "{}:{}", path.strip_prefix(env!("CARGO_MANIFEST_DIR")) .unwrap_or(&path) .display(), line_no + 1 )); } } } } }