Add Cobertura XML output to `src-cov` example binary
@@ -24,6 +24,9 @@ struct Opt {
#[structopt(short, long, long_help = "Timeout in ms", default_value = "5000")]
timeout: u64,
+
+ #[structopt(short = "x", long)]
+ cobertura_xml: bool,
}
fn main() -> Result<()> {
@@ -38,7 +41,7 @@ fn main() -> Result<()> {
for entry in std::fs::read_dir(dir)? {
let input = entry?.path();
- println!("testing input: {}", input.display());
+ eprintln!("testing input: {}", input.display());
let cmd = input_command(&opt.cmd, &input);
let coverage = record(&mut cache, filter.clone(), cmd, timeout)?;
@@ -48,7 +51,7 @@ fn main() -> Result<()> {
}
for input in &opt.inputs {
- println!("testing input: {}", input.display());
+ eprintln!("testing input: {}", input.display());
let cmd = input_command(&opt.cmd, input);
let coverage = record(&mut cache, filter.clone(), cmd, timeout)?;
@@ -59,6 +62,10 @@ fn main() -> Result<()> {
let mut debug_info = coverage::debuginfo::DebugInfo::default();
let src_coverage = total.source_coverage(&mut debug_info)?;
+ if opt.cobertura_xml {
+ let cobertura = coverage::cobertura::cobertura(src_coverage)?;
+ println!("{}", cobertura);
+ } else {
for file_coverage in src_coverage.files {
for location in &file_coverage.locations {
println!(
@@ -67,6 +74,7 @@ fn main() -> Result<()> {
);
}
}
+ }
Ok(())
}
