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 2 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
9 changes: 9 additions & 0 deletions src/agent/onefuzz-agent/src/tasks/coverage/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use coverage::block::CommandBlockCov;
use coverage::cache::ModuleCache;
use coverage::code::{CmdFilter, CmdFilterDef};
use coverage::debuginfo::DebugInfo;
use coverage::cobertura::cobertura;
use onefuzz::expand::{Expand, PlaceHolder};
use onefuzz::syncdir::SyncedDir;
use onefuzz_telemetry::{warn, Event::coverage_data, EventData};
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.txt";
hayleycall marked this conversation as resolved.
Show resolved Hide resolved
const MODULE_CACHE_FILE: &str = "module-cache.json";

const DEFAULT_TARGET_TIMEOUT: Duration = Duration::from_secs(5);
Expand Down Expand Up @@ -362,6 +364,13 @@ 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)?;
let text = &cobertura_source_coverage;
hayleycall marked this conversation as resolved.
Show resolved Hide resolved
fs::write(&path, &text)
.await
hayleycall marked this conversation as resolved.
Show resolved Hide resolved
.with_context(|| format!("writing cobertura source coverage to {}", path.display()))?;

self.config.coverage.sync_push().await?;

Ok(())
Expand Down