| 125 | } |
| 126 | |
| 127 | fn merge_profraw(llvm_profdata: &Path, profraw_dir: &Path, profdata_file: &Path) { |
| 128 | eprintln!("=== Merging profraw files ==="); |
| 129 | let profraw_files: Vec<_> = fs::read_dir(profraw_dir) |
| 130 | .expect("failed to read profraw dir") |
| 131 | .filter_map(|e| { |
| 132 | let path = e.ok()?.path(); |
| 133 | if path.extension().is_some_and(|ext| ext == "profraw") { |
| 134 | Some(path) |
| 135 | } else { |
| 136 | None |
| 137 | } |
| 138 | }) |
| 139 | .collect(); |
| 140 | |
| 141 | if profraw_files.is_empty() { |
| 142 | eprintln!( |
| 143 | "error: no .profraw files found in {}", |
| 144 | profraw_dir.display() |
| 145 | ); |
| 146 | std::process::exit(1); |
| 147 | } |
| 148 | eprintln!(" merging {} profraw files", profraw_files.len()); |
| 149 | |
| 150 | let mut cmd = Command::new(llvm_profdata); |
| 151 | cmd.arg("merge").arg("-sparse"); |
| 152 | for f in &profraw_files { |
| 153 | cmd.arg(f); |
| 154 | } |
| 155 | cmd.arg("-o").arg(profdata_file); |
| 156 | let status = cmd.status().expect("failed to run llvm-profdata"); |
| 157 | if !status.success() { |
| 158 | eprintln!("llvm-profdata merge failed with {status}"); |
| 159 | std::process::exit(1); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | fn generate_report(llvm_cov: &Path, binaries: &[String], profdata_file: &Path, report_dir: &Path) { |
| 164 | eprintln!("=== Generating HTML coverage report ==="); |