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

Add support for lcov output #643

Open
4 of 24 tasks
chintans opened this issue Nov 22, 2016 · 6 comments
Open
4 of 24 tasks

Add support for lcov output #643

chintans opened this issue Nov 22, 2016 · 6 comments

Comments

@chintans
Copy link

Please provide the following information when submitting an issue, where appropriate replace the [ ] with a [X]

My Framework

  • .NET 2
  • .NET 3.5
  • .NET 4
  • .NET 4.5
  • .NET 4.6
  • .NET 4.6.1
  • .NET 4.6.2
  • .NET Core 1.0.0
  • Something else

My Environment

  • Windows 7 or below (not truly supported due to EOL)
  • Windows 8
  • Windows 8.1
  • Windows 10
  • Windows 10 IoT Core
  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows Server 2016

I have already...

  • repeated the problem using the latest stable release of OpenCover.
  • reviewed the usage guide and usage document.
  • have looked at the opencover output XML file in an attempt to resolve the issue.
  • reviewed the current issues to check that the issue isn't already known.

My issue is related to (check only those which apply):

  • no coverage being recorded
  • 32 or 64 bit support
  • feature request

Expected Behavior

Many of the modern projects have a lot of the logic written on front-end in a javascript framework. Most of the javascript testing framework and coverage frameworks generate lcov file for coverage. When, we use code coverage reporter service like coveralls. They take a single file as input. It can either be OpenCover.xml or coverage.lcov. If we want to combine both files, we wither have to do XML to lcov or lcov to XML conversion and merge both files and submit it to the service. It becomes hectic for each project. It would be a nice feature we could specify lcov format of output in opencover. Then we are left with the task of merging the files only.

Just to summarise, I am looking for support of lcov output format.

Actual Behavior

Fill me in...

Steps to reproduce the problem:

Fill me in...

@sawilde
Copy link
Member

sawilde commented Nov 22, 2016

do you have the XML to LCOV converter - perhaps we can just chain that in.

@chintans
Copy link
Author

I tried searching for it but couldn't find anything useful.

@sawilde
Copy link
Member

sawilde commented Nov 23, 2016

If we want to combine both files, we wither have to do XML to lcov or lcov to XML conversion and merge both files and submit it to the service

I assumed from this statement it was something you were doing already - no worries.

@SteveGilham
Copy link
Contributor

The LCOV format is really as simple as documented here -- a whole lot of sections, starting with a TN: (which can be empty) and an SF: for the file which this block is concerned with, then all the other records, and ending with end_of_record.

@SteveGilham
Copy link
Contributor

SteveGilham commented Sep 3, 2017

Here's a quick and dirty powershell script that should do OpenCover to lcov format; the main thing that might need tweaking is the branch block-number, which I've used the offset value for. If this has to be unique across more than a single method, then it would want to be something like (offset + 1000 * line number) to make unique per file

param ([string]$OpenCoverPath)

$x = [xml](Get-Content $OpenCoverPath)
$x.CoverageSession.Modules.Module.Files.File | % {
  Write-Output "TN:"
  Write-Output "SF:$($_.fullPath)"
  $uid = $_.uid
  $p = $_.ParentNode.ParentNode
  $methods = $p.Classes.Class.Methods.Method | ? { $_.FileRef.uid -eq $uid } 
  $methods | % {
    $s = $_.SequencePoints.SequencePoint
    if ($s) {
        $l = $s[0].sl
        if($l) {
            Write-Output "FN:$l,$($_.Name)"
        }
    }
  }

  $methods | % {
      $s = $_.SequencePoints.SequencePoint
      if ($s) {
        $l = $s[0].sl
        if($l) {
            Write-Output "FNDA:$($_.MethodPoint.vc),$($_.Name)"
        }
      }
  }

  Write-Output "FNF:$($Methods.Length)"
  $hit = $methods | ? { $_.visited -eq "true" }
  Write-Output "FNH:$($hit.Length)"

  $brf = 0
  $brh = 0
  $methods | % {
      $_.Branchpoints.BranchPoint | % {
         if ($_.sl) {
            $brf += 1
            if ([int]($_.vc)) { $brh += 1 }
            Write-Output "BRDA:$($_.sl),$($_.offset),$($_.path),$($_.vc)"
        }
      }
  }
  Write-Output "BRF:$brf"
  Write-Output "BRH:$brh"

  $lf = 0
  $lh = 0
  $methods | % {
      $_.SequencePoints.SequencePoint | % {
         if ($_.sl) {
            $lf += 1
            if ([int]($_.vc)) { $lh += 1 }
            Write-Output "DA:$($_.sl),$($_.vc)"
        }
      }
  }
  Write-Output "LF:$lf"
  Write-Output "LH:$lh"

  Write-Output "end_of_record"
}

@equiman
Copy link

equiman commented Jan 23, 2018

It will be great, because on vscode there is only Coverage plugins that use lcov format and no one other support xml report from Open Coverage.

SteveGilham added a commit to SteveGilham/altcover that referenced this issue Apr 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants