()
| 19 | use std::process::{Command, Stdio}; |
| 20 | |
| 21 | fn main() { |
| 22 | let root = find_repo_root(); |
| 23 | let args: Vec<_> = env::args().skip(1).collect(); |
| 24 | |
| 25 | let profraw_dir = root.join("target/coverage-profraw"); |
| 26 | let profdata_file = root.join("target/coverage.profdata"); |
| 27 | let report_dir = root.join("report"); |
| 28 | |
| 29 | if profraw_dir.exists() { |
| 30 | fs::remove_dir_all(&profraw_dir).expect("failed to clean profraw dir"); |
| 31 | } |
| 32 | fs::create_dir_all(&profraw_dir).expect("failed to create profraw dir"); |
| 33 | |
| 34 | let llvm_profdata = find_llvm_tool("llvm-profdata"); |
| 35 | let llvm_cov = find_llvm_tool("llvm-cov"); |
| 36 | |
| 37 | let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default(); |
| 38 | if !rustflags.is_empty() { |
| 39 | rustflags.push(' '); |
| 40 | } |
| 41 | rustflags.push_str("-C instrument-coverage"); |
| 42 | |
| 43 | let profraw_pattern = profraw_dir.join("%m_%p.profraw"); |
| 44 | |
| 45 | run_tests(&root, &args, &rustflags, &profraw_pattern); |
| 46 | let binaries = discover_test_binaries(&root, &args, &rustflags, &profraw_pattern); |
| 47 | merge_profraw(&llvm_profdata, &profraw_dir, &profdata_file); |
| 48 | generate_report(&llvm_cov, &binaries, &profdata_file, &report_dir); |
| 49 | } |
| 50 | |
| 51 | fn run_tests(root: &Path, args: &[String], rustflags: &str, profraw_pattern: &Path) { |
| 52 | eprintln!("=== Running cargo test with coverage ==="); |
nothing calls this directly
no test coverage detected