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

Integrate Cobertura format and output as file in coverage container #1572

Merged
merged 5 commits into from
Jan 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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