WIP: fixture test for the test-module file exclusion
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -244,6 +244,26 @@ fn char_end(c: &[char], i: usize) -> Option<usize> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The walk itself drops a `#[cfg(test)] mod x;` file, not only the parts
|
||||
/// that find one. A fixture tree, because the wiring is the thing tested.
|
||||
#[test]
|
||||
fn a_test_only_module_file_is_not_production_code() {
|
||||
let root = std::env::temp_dir().join(format!("source_scan_{}", std::process::id()));
|
||||
let src = root.join("src");
|
||||
std::fs::create_dir_all(src.join("t")).unwrap();
|
||||
std::fs::write(src.join("lib.rs"), "mod p;\n#[cfg(test)]\nmod t;\n").unwrap();
|
||||
std::fs::write(src.join("p.rs"), "fn production() {}\n").unwrap();
|
||||
std::fs::write(src.join("t.rs"), "fn test_only() {}\nmod deeper;\n").unwrap();
|
||||
std::fs::write(src.join("t").join("deeper.rs"), "fn test_too() {}\n").unwrap();
|
||||
let mut found: Vec<String> = production_code(&[src.clone()])
|
||||
.into_iter()
|
||||
.map(|(file, _)| file.strip_prefix(&src).unwrap().display().to_string())
|
||||
.collect();
|
||||
found.sort();
|
||||
std::fs::remove_dir_all(&root).unwrap();
|
||||
assert_eq!(found, vec!["lib.rs", "p.rs"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_only_items_and_modules_are_not_production() {
|
||||
let text = concat!(
|
||||
|
||||
Reference in New Issue
Block a user