Skip to content

Commit

Permalink
refactor: lcov reporter dest
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Jun 22, 2022
1 parent 451adb2 commit 534ec77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cli/src/cmd/forge/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl CoverageArgs {
CoverageReportKind::Summary => SummaryReporter::default().report(map),
// TODO: Sensible place to put the LCOV file
CoverageReportKind::Lcov => {
LcovReporter::new(std::fs::File::create(root.join("lcov.info"))?).report(map)
LcovReporter::new(&mut std::fs::File::create(root.join("lcov.info"))?).report(map)
}
CoverageReportKind::Debug => DebugReporter::default().report(map),
}
Expand Down
15 changes: 6 additions & 9 deletions forge/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,19 @@ fn format_cell(hits: usize, total: usize) -> Cell {
cell
}

pub struct LcovReporter<W> {
pub struct LcovReporter<'a> {
/// Destination buffer
destination: W,
destination: &'a mut (dyn Write + 'a),
}

impl<W> LcovReporter<W> {
pub fn new(destination: W) -> Self {
impl<'a> LcovReporter<'a> {
pub fn new(destination: &'a mut (dyn Write + 'a)) -> LcovReporter<'a> {
Self { destination }
}
}

impl<W> CoverageReporter for LcovReporter<W>
where
W: Write,
{
fn report(mut self, map: CoverageMap) -> eyre::Result<()> {
impl<'a> CoverageReporter for LcovReporter<'a> {
fn report(self, map: CoverageMap) -> eyre::Result<()> {
for file in map {
let summary = file.summary();

Expand Down

0 comments on commit 534ec77

Please sign in to comment.