huskies: merge 468_story_exclude_git_worktrees_from_loc_command_output

This commit is contained in:
dave
2026-04-04 11:06:48 +00:00
parent 656a840607
commit 6b7c3bb450
+36
View File
@@ -337,6 +337,42 @@ mod tests {
); );
} }
#[test]
fn loc_skips_target_directory() {
use std::io::Write as _;
let dir = tempfile::tempdir().expect("tempdir");
// Create a target/ subdirectory with a .rs file — it must NOT appear.
let target_dir = dir.path().join("target");
std::fs::create_dir(&target_dir).unwrap();
let hidden = target_dir.join("huge_generated.rs");
{
let mut f = std::fs::File::create(&hidden).unwrap();
for i in 0..1000 {
writeln!(f, "fn generated_{i}() {{}}").unwrap();
}
}
// Real source file at the root — must appear.
let source = dir.path().join("lib.rs");
{
let mut f = std::fs::File::create(&source).unwrap();
for i in 0..5 {
writeln!(f, "fn f{i}() {{}}").unwrap();
}
}
let agents = Arc::new(AgentPool::new_test(3000));
let ambient_rooms = Arc::new(Mutex::new(HashSet::new()));
let ctx = make_ctx(&agents, &ambient_rooms, dir.path(), "50");
let output = handle_loc(&ctx).unwrap();
assert!(
!output.contains("target/"),
"output must not include files under target/: {output}"
);
assert!(
output.contains("lib.rs"),
"lib.rs should appear in loc output: {output}"
);
}
#[test] #[test]
fn loc_excludes_lockfiles_from_results() { fn loc_excludes_lockfiles_from_results() {
use std::io::Write as _; use std::io::Write as _;