Skip to content

Commit 0814226

Browse files
committed
Update coverage
1 parent a004362 commit 0814226

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

util/collect_coverage/collect_coverage.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,28 +147,37 @@ fn main() {
147147
.arg("-format=lcov")
148148
.arg("-instr-profile")
149149
.arg(&profdata_file)
150-
.arg("-ignore-filename-regex='.*external/.+'")
151-
.arg("-ignore-filename-regex='/tmp/.+'")
152-
.arg(format!("-path-equivalence=.,'{}'", execroot.display()))
150+
.arg("-ignore-filename-regex=.*external/.+")
151+
.arg("-ignore-filename-regex=/tmp/.+")
152+
.arg(format!("-path-equivalence=.,{}", execroot.display()))
153153
.arg(test_binary)
154154
.stdout(process::Stdio::piped());
155155

156156
debug_log!("Spawning {:#?}", llvm_cov_cmd);
157-
let child = llvm_cov_cmd
158-
.spawn()
157+
let output = llvm_cov_cmd
158+
.stderr(process::Stdio::piped())
159+
.output()
159160
.expect("Failed to spawn llvm-cov process");
160161

161-
let output = child.wait_with_output().expect("llvm-cov process failed");
162+
if !output.status.success() {
163+
let stderr = String::from_utf8_lossy(&output.stderr);
164+
eprintln!(
165+
"llvm-cov export failed with status {}: {}",
166+
output.status, stderr
167+
);
168+
process::exit(output.status.code().unwrap_or(1));
169+
}
162170

163-
// Parse the child process's stdout to a string now that it's complete.
164171
debug_log!("Parsing llvm-cov output");
165172
let report_str = std::str::from_utf8(&output.stdout).expect("Failed to parse llvm-cov output");
166173

167174
debug_log!("Writing output to {}", coverage_output_file.display());
175+
let execroot_prefix = format!("{}/", execroot.display());
168176
fs::write(
169177
coverage_output_file,
170178
report_str
171179
.replace("#/proc/self/cwd/", "")
180+
.replace(&execroot_prefix, "")
172181
.replace(&execroot.display().to_string(), ""),
173182
)
174183
.unwrap();

0 commit comments

Comments
 (0)