Skip to content

Commit

Permalink
chore: Add debug logging
Browse files Browse the repository at this point in the history
Looking at how --ignore works
  • Loading branch information
winksaville committed Aug 20, 2022
1 parent 87f9e9f commit a843d92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ fn main() {
let (sender, receiver) = bounded(2 * num_threads); let (sender, receiver) = bounded(2 * num_threads);
let path_mapping: Arc<Mutex<Option<Value>>> = Arc::new(Mutex::new(None)); let path_mapping: Arc<Mutex<Option<Value>>> = Arc::new(Mutex::new(None));


println!("main: opt.paths={:?}", opt.paths);
let producer = { let producer = {
let sender: JobSender = sender.clone(); let sender: JobSender = sender.clone();
let tmp_path = tmp_path.clone(); let tmp_path = tmp_path.clone();
Expand Down
22 changes: 19 additions & 3 deletions src/path_rewriting.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ pub fn rewrite_paths(
filter_option: Option<bool>, filter_option: Option<bool>,
file_filter: crate::FileFilter, file_filter: crate::FileFilter,
) -> CovResultIter { ) -> CovResultIter {
println!("rewrite_paths: X source_dir={:?}", source_dir);
print!("rewrite_paths: ignore_dirs=");
to_ignore_dirs.into_iter().for_each(|e| print!("{}, ", e.as_ref()));
println!();
let to_ignore_globset = to_globset(to_ignore_dirs); let to_ignore_globset = to_globset(to_ignore_dirs);
println!("rewrite_paths: to_ignore_globset.len={}", to_ignore_globset.len());
let to_keep_globset = to_globset(to_keep_dirs); let to_keep_globset = to_globset(to_keep_dirs);


if let Some(p) = &source_dir { if let Some(p) = &source_dir {
Expand All @@ -250,23 +255,33 @@ pub fn rewrite_paths(
.into_iter() .into_iter()
.filter_entry(|e| !is_hidden(e) && !is_symbolic_link(e)) .filter_entry(|e| !is_hidden(e) && !is_symbolic_link(e))
{ {
//println!("this is entry path: {:?}", entry);
let entry = entry let entry = entry
.unwrap_or_else(|_| panic!("Failed to open directory '{}'.", source_dir.display())); .unwrap_or_else(|_| panic!("Failed to open directory '{}'.", source_dir.display()));



let full_path = entry.path(); let full_path = entry.path();
if !full_path.is_file() { if !full_path.is_file() {
//println!("ignoring dir: {:?}", full_path);
continue; continue;
} }


println!("checking full_path: {:?}", full_path);
let path = full_path.strip_prefix(&source_dir).unwrap().to_path_buf(); let path = full_path.strip_prefix(&source_dir).unwrap().to_path_buf();
println!("checking stripped: {:?}", path);
if to_ignore_globset.is_match(&path) { if to_ignore_globset.is_match(&path) {
println!("ignoring path: {:?}", path);
continue; continue;
} }


let name = entry.file_name().to_str().unwrap().to_string(); let name = entry.file_name().to_str().unwrap().to_string();
match file_to_paths.entry(name) { match file_to_paths.entry(name.clone()) {
hash_map::Entry::Occupied(f) => f.into_mut().push(path), hash_map::Entry::Occupied(f) => {
//println!("for '{name}' push: '{path:?}'");
f.into_mut().push(path)
}
hash_map::Entry::Vacant(v) => { hash_map::Entry::Vacant(v) => {
//println!("for '{name}' insert: '{path:?}'");
v.insert(vec![path]); v.insert(vec![path]);
} }
}; };
Expand Down Expand Up @@ -295,6 +310,7 @@ pub fn rewrite_paths(
let (abs_path, rel_path) = get_abs_path(source_dir, rel_path)?; let (abs_path, rel_path) = get_abs_path(source_dir, rel_path)?;


if to_ignore_globset.is_match(&rel_path) { if to_ignore_globset.is_match(&rel_path) {
println!("results: to_ignore_globset, ignoring: {:?}", rel_path);
return None; return None;
} }


Expand Down Expand Up @@ -340,7 +356,7 @@ pub fn rewrite_paths(


Some((abs_path, rel_path, result)) Some((abs_path, rel_path, result))
}); });

//println!("rewrite_paths: result={:#?}", results);
Box::new( Box::new(
results results
.collect::<Vec<(PathBuf, PathBuf, CovResult)>>() .collect::<Vec<(PathBuf, PathBuf, CovResult)>>()
Expand Down

0 comments on commit a843d92

Please sign in to comment.