Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Integrate Cobertura format and output as file in coverage container (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
hayleycall authored Jan 11, 2022
1 parent e89e7b2 commit d28ad25
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/agent/onefuzz-agent/src/tasks/coverage/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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);
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit d28ad25

Please sign in to comment.