Skip to content

Commit

Permalink
Be more verbose when gcov fails (#233)
Browse files Browse the repository at this point in the history
* Be more verbose when gcov fails

* Remove unneeded commented-out code

* Improved wording
  • Loading branch information
marco-c authored and calixteman committed Jan 9, 2019
1 parent 9067050 commit 5d6715d
Showing 1 changed file with 10 additions and 46 deletions.
56 changes: 10 additions & 46 deletions src/gcov.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
use semver::Version;
use std::env;
use std::path::PathBuf;
use std::process::{Command, Stdio};

/*
#[link(name = "gcov")]
extern {
fn __gcov_read_unsigned() -> u32;
fn __gcov_open(name: *const c_char) -> i32;
fn __gcov_close();
}
fn gcov_open(file: String) -> i32 {
let c_to_print = CString::new(file).unwrap();
return unsafe { __gcov_open(c_to_print.as_ptr()) };
}
fn gcov_read_unsigned() -> u32 {
return unsafe { __gcov_read_unsigned() };
}
fn prova() {
if gcov_open("/home/marco/Documenti/workspace/grcov/tests/llvm/main.gcda".to_string()) == 1 {
println!("2");
}
println!("{:x}", gcov_read_unsigned());
if gcov_open("/home/marco/Documenti/workspace/grcov/tests/basic/main.gcda".to_string()) == 1 {
println!("1");
}
println!("{:x}", gcov_read_unsigned());
}*/
use std::process::Command;

fn get_gcov() -> String {
match env::var("GCOV") {
Expand All @@ -51,21 +20,16 @@ pub fn run_gcov(gcno_path: &PathBuf, branch_enabled: bool, working_dir: &PathBuf
let status = command
.arg(gcno_path)
.arg("-i") // Generate intermediate gcov format, faster to parse.
.current_dir(working_dir)
.stdout(Stdio::null())
.stderr(Stdio::null());
.current_dir(working_dir);

/*if cfg!(unix) {
status.spawn()
.expect("Failed to execute gcov process");
} else {*/
let status = status.status().expect("Failed to execute gcov process");
assert!(
status.success(),
"gcov wasn't successfully executed on {}",
gcno_path.display()
);
//}
let output = status.output().expect("Failed to execute gcov process");

if !output.status.success() {
eprintln!("gcov stdout: {}", String::from_utf8_lossy(&output.stdout));
eprintln!("gcov stderr: {}", String::from_utf8_lossy(&output.stderr));

panic!("gcov execution failed on {}", gcno_path.display());
}
}

fn is_recent_version(gcov_output: &str) -> bool {
Expand Down

0 comments on commit 5d6715d

Please sign in to comment.