MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / main

Function main

scripts/coverage.rs:21–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19use std::process::{Command, Stdio};
20
21fn 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
51fn run_tests(root: &Path, args: &[String], rustflags: &str, profraw_pattern: &Path) {
52 eprintln!("=== Running cargo test with coverage ===");

Callers

nothing calls this directly

Calls 14

find_repo_rootFunction · 0.85
find_llvm_toolFunction · 0.85
run_testsFunction · 0.85
discover_test_binariesFunction · 0.85
merge_profrawFunction · 0.85
generate_reportFunction · 0.85
collectMethod · 0.80
existsMethod · 0.80
skipMethod · 0.45
joinMethod · 0.45
expectMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected