Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jandelgado/gcov2lcov
convert go coverage files to lcov format
https://github.com/jandelgado/gcov2lcov
coverage golang lcov testing
Last synced: 2 days ago
JSON representation
convert go coverage files to lcov format
- Host: GitHub
- URL: https://github.com/jandelgado/gcov2lcov
- Owner: jandelgado
- License: mit
- Created: 2019-10-04T21:36:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-28T09:33:29.000Z (about 1 month ago)
- Last Synced: 2024-12-30T22:08:19.874Z (9 days ago)
- Topics: coverage, golang, lcov, testing
- Language: Go
- Size: 48.8 KB
- Stars: 52
- Watchers: 3
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gcov2lcov
[![Build Status](https://github.com/jandelgado/gcov2lcov/workflows/run%20tests/badge.svg)](https://github.com/jandelgado/gcov2lcov/actions?workflow=run%20tests)
[![Coverage Status](https://coveralls.io/repos/github/jandelgado/gcov2lcov/badge.svg?branch=master)](https://coveralls.io/github/jandelgado/gcov2lcov?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/jandelgado/gcov2lcov)](https://goreportcard.com/report/github.com/jandelgado/gcov2lcov)Convert golang test coverage to lcov format (which can for example be uploaded
to coveralls).See [gcov2lcov-action](https://github.com/jandelgado/gcov2lcov-action)
for a github action which uses this tool.## Credits
This tool is based on [covfmt](https://github.com/ricallinson/covfmt) and
uses some parts of [goveralls](https://github.com/mattn/goveralls).## Installation
### Binary download
Download a version for your platform from the [Releases](https://github.com/jandelgado/gcov2lcov/releases) page.
You may have noticed that the file `gcov2lcov-linux-amd64.tar.gz` does not
follow the naming convention used for other artifacts. This particular file is
provided for backward compatibility with the `gcov2lcov-action` and can be
disregarded for general use.### Compile from source
```text
$ go install github.com/jandelgado/gcov2lcov@latest
```## Usage
```text
Usage of ./gcov2lcov:
-infile string
go coverage file to read, default:
-outfile string
lcov file to write, default:
-use-absolute-source-path
use absolute paths for source file in lcov output, default: false
```### Example
```sh
$ go test -coverprofile=coverage.out && \
gcov2lcov -infile=coverage.out -outfile=coverage.lcov
```### GOROOT
It might be necessary to set the `GOROOT` environment variable properly before
calling `gcov2lcov`. If you see `cannot find GOROOT directory` warnings like
e.g.```text
022/05/23 16:00:58 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64
```Then call `gcov2lcov` with
```text
$ GOROOT=$(go env GOROOT) gcov2lcov -infile=coverage.out -outfile=coverage.lcov
```## Build and Test
* `make test` to run tests
* `make build` to build binary in `bin/` directory## Tracefile format reference
The following desription is taken from the [geninfo
manpage](http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php) of the [lcov
homepage](http://ltp.sourceforge.net/coverage/lcov/):```text
A tracefile is made up of several human-readable lines of text, divided into
sections. If available, a tracefile begins with the testname which is stored in
the following format:TN:
For each source file referenced in the .da file, there is a section containing
filename and coverage data:SF:
Following is a list of line numbers for each function name found in the source file:
FN:,
Next, there is a list of execution counts for each instrumented function:
FNDA:,
This list is followed by two lines containing the number of functions found and hit:
FNF: FNH:
Branch coverage information is stored which one line per branch:
BRDA:,,,
Block number and branch number are gcc internal IDs for the branch. Taken is
either '-' if the basic block containing the branch was never executed or a
number indicating how often that branch was taken.Branch coverage summaries are stored in two lines:
BRF: BRH:
Then there is a list of execution counts for each instrumented line (i.e. a
line which resulted in executable code):DA:,[,]
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 and
how many were actually instrumented:LH: LF:
Each sections ends with:
end_of_record
In addition to the main source code file there are sections for all #included
files which also contain executable code.Note that the absolute path of a source file is generated by interpreting the
contents of the respective .bb file (see gcov (1) for more information on this
file type). Relative filenames are prefixed with the directory in which the .bb
file is found.Note also that symbolic links to the .bb file will be resolved so that the
actual file path is used instead of the path to a link. This approach is
necessary for the mechanism to work with the /proc/gcov files.```
## Author
Jan Delgado
## License
MIT