//! A read-only sweep probe: set CENSUS to a directory and this prints the //! covergroup structured/fallback counts and the tolerant diagnostics over //! every `.sv`/`.svh` under it. Ignored; run by hand for the feature README. use std::path::{Path, PathBuf}; fn collect(dir: &Path, out: &mut Vec) { let Ok(entries) = std::fs::read_dir(dir) else { return }; for e in entries.flatten() { let p = e.path(); if p.is_dir() { collect(&p, out); } else if matches!(p.extension().and_then(|s| s.to_str()), Some("sv") | Some("svh")) { out.push(p); } } } #[test] #[ignore] fn census() { std::thread::Builder::new() .stack_size(vlog_parser::PARSE_STACK_SIZE) .spawn(run) .expect("spawn") .join() .expect("join"); } fn run() { let root = std::env::var("CENSUS").expect("CENSUS"); let mut files = Vec::new(); collect(Path::new(&root), &mut files); files.sort(); let (mut cg, mut fb, mut cf, mut diags, mut with_diags) = (0u64, 0u64, 0u64, 0u64, 0u64); for p in &files { let Ok(src) = std::fs::read_to_string(p) else { continue }; let (file, ds) = vlog_parser::parse_source_tolerant(&src); cg += u64::from(file.covergroups); fb += u64::from(file.covergroup_fallbacks); cf += u64::from(file.constraint_fallbacks); if file.covergroup_fallbacks > 0 { println!("FALLBACK {} {}", p.display(), file.covergroup_fallbacks); } if !ds.is_empty() { with_diags += 1; println!("DIAGS {} {}", p.display(), ds.len()); } diags += ds.len() as u64; } println!( "files={} covergroups={cg} covergroup_fallbacks={fb} constraint_fallbacks={cf} diagnostics={diags} files_with_diagnostics={with_diags}", files.len() ); }