- Notifications
You must be signed in to change notification settings - Fork12
convert go coverage files to lcov format
License
jandelgado/gcov2lcov
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Convert golang test coverage to lcov format (which can for example be uploadedto coveralls).
Seegcov2lcov-actionfor a github action which uses this tool.
This tool is based oncovfmt anduses some parts ofgoveralls.
Download a version for your platform from theReleases page.
You may have noticed that the filegcov2lcov-linux-amd64.tar.gz
does notfollow the naming convention used for other artifacts. This particular file isprovided for backward compatibility with thegcov2lcov-action
and can bedisregarded for general use.
$ go install github.com/jandelgado/gcov2lcov@latest
Usage of ./gcov2lcov: -infile string go coverage file to read, default: <stdin> -outfile string lcov file to write, default: <stdout> -use-absolute-source-path use absolute paths for source file in lcov output, default: false
$ gotest -coverprofile=coverage.out&& \gcov2lcov -infile=coverage.out -outfile=coverage.lcov
It might be necessary to set theGOROOT
environment variable properly beforecallinggcov2lcov
. If you seecannot find GOROOT directory
warnings likee.g.
022/05/23 16:00:58 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64
Then callgcov2lcov
with
$ GOROOT=$(go env GOROOT) gcov2lcov -infile=coverage.out -outfile=coverage.lcov
make test
to run testsmake build
to build binary inbin/
directory
The following desription is taken from thegeninfomanpage of thelcovhomepage:
A tracefile is made up of several human-readable lines of text, divided intosections. If available, a tracefile begins with the testname which is stored inthe following format:TN:<test name>For each source file referenced in the .da file, there is a section containingfilename and coverage data:SF:<absolute path to the source file>Following is a list of line numbers for each function name found in the source file:FN:<line number of function start>,<function name>Next, there is a list of execution counts for each instrumented function:FNDA:<execution count>,<function name>This list is followed by two lines containing the number of functions found and hit:FNF:<number of functions found> FNH:<number of function hit>Branch coverage information is stored which one line per branch:BRDA:<line number>,<block number>,<branch number>,<taken>Block number and branch number are gcc internal IDs for the branch. Taken iseither '-' if the basic block containing the branch was never executed or anumber indicating how often that branch was taken.Branch coverage summaries are stored in two lines:BRF:<number of branches found> BRH:<number of branches hit>Then there is a list of execution counts for each instrumented line (i.e. aline which resulted in executable code):DA:<line number>,<execution count>[,<checksum>]Note that there may be an optional checksum present for each instrumented line.The current geninfo implementation uses an MD5 hash as checksumming algorithm.At the end of a section, there is a summary about how many lines were found andhow many were actually instrumented:LH:<number of lines with a non-zero execution count> LF:<number of instrumented lines>Each sections ends with:end_of_recordIn addition to the main source code file there are sections for all #includedfiles which also contain executable code.Note that the absolute path of a source file is generated by interpreting thecontents of the respective .bb file (see gcov (1) for more information on thisfile type). Relative filenames are prefixed with the directory in which the .bbfile is found.Note also that symbolic links to the .bb file will be resolved so that theactual file path is used instead of the path to a link. This approach isnecessary for the mechanism to work with the /proc/gcov files.
Jan Delgado
MIT
About
convert go coverage files to lcov format
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.