mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-23 14:57:06 +00:00
Integrate Cobertura format and output as file in coverage container (#1572)
* Integrate cobertura format and output as file in coverage container * cobertura output file is txt, not json * Format * xml file not txt * Improved syntax
This commit is contained in:
@ -11,6 +11,7 @@ use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use coverage::block::CommandBlockCov;
|
||||
use coverage::cache::ModuleCache;
|
||||
use coverage::cobertura::cobertura;
|
||||
use coverage::code::{CmdFilter, CmdFilterDef};
|
||||
use coverage::debuginfo::DebugInfo;
|
||||
use onefuzz::expand::{Expand, PlaceHolder};
|
||||
@ -30,6 +31,7 @@ use crate::tasks::heartbeat::{HeartbeatSender, TaskHeartbeatClient};
|
||||
const MAX_COVERAGE_RECORDING_ATTEMPTS: usize = 2;
|
||||
const COVERAGE_FILE: &str = "coverage.json";
|
||||
const SOURCE_COVERAGE_FILE: &str = "source-coverage.json";
|
||||
const COBERTURA_COVERAGE_FILE: &str = "cobertura-coverage.xml";
|
||||
const MODULE_CACHE_FILE: &str = "module-cache.json";
|
||||
|
||||
const DEFAULT_TARGET_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
@ -362,6 +364,16 @@ impl<'a> TaskContext<'a> {
|
||||
.await
|
||||
.with_context(|| format!("writing source coverage to {}", path.display()))?;
|
||||
|
||||
let path = self
|
||||
.config
|
||||
.coverage
|
||||
.local_path
|
||||
.join(COBERTURA_COVERAGE_FILE);
|
||||
let cobertura_source_coverage = cobertura(src_coverage)?;
|
||||
fs::write(&path, &cobertura_source_coverage)
|
||||
.await
|
||||
.with_context(|| format!("writing cobertura source coverage to {}", path.display()))?;
|
||||
|
||||
self.config.coverage.sync_push().await?;
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user