Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jack-r-warren/remove_from_coverage
A command-line tool to customize the contents of a coverage lcov.info file
https://github.com/jack-r-warren/remove_from_coverage
Last synced: 6 days ago
JSON representation
A command-line tool to customize the contents of a coverage lcov.info file
- Host: GitHub
- URL: https://github.com/jack-r-warren/remove_from_coverage
- Owner: jack-r-warren
- License: bsd-3-clause
- Created: 2019-05-20T03:19:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T04:51:59.000Z (almost 2 years ago)
- Last Synced: 2024-11-03T18:34:28.846Z (2 months ago)
- Language: Dart
- Homepage: https://pub.dev/packages/remove_from_coverage
- Size: 33.2 KB
- Stars: 20
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Remove from Coverage
> Author: [Jack Warren](https://jackwarren.info)[![Build Status](https://travis-ci.com/jack-r-warren/remove_from_coverage.svg?branch=master)](https://travis-ci.com/jack-r-warren/remove_from_coverage) [![Pub](https://img.shields.io/pub/v/remove_from_coverage.svg)](https://pub.dartlang.org/packages/remove_from_coverage)
Manipulate `lcov.info` coverage files to ignore files matching given patterns. This can be used to exclude generated files from coverage reports, and is language-agnostic.
```text
Remove files with paths matching given PATTERNs from the lcov.info FILE
-f, --file= the target lcov.info file to manipulate
-r, --remove= a pattern of paths to exclude from coverage
-h, --help show this help
```The patterns are used to construct `RegExp` objects, so `-r "\.g\.dart$"` becomes `RegExp('\.g\.dart$')`. Multiple patterns may be provided by either providing `-r` multiple times or by using comma-separation, like `-r '\.g\.dart$', 'main\.dart'`. When evaluating a file's entry in the `lcov.info`, if its path matches any pattern it will be excluded. The paths are relative from the project's root.
If a `lcov.info` file is not provided via the `-f` flag, `stdin` input is run through the program's filter and is sent to `stdout`.
## Example
Suppose you want to remove generated files ending in `.g.dart` from code coverage reports:- We'll target the `lcov.info` file in the `coverage` directory
- We'll use `\.g\.dart$` as the patternIf [`pub global` scripts are on your path](https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path), you can use the following:
```bash
remove_from_coverage -f coverage/lcov.info -r "\.g\.dart$"
```Otherwise, [you can use the following](https://dart.dev/tools/pub/cmd/pub-global#running-a-script-using-pub-global-run):
```bash
pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r "\.g\.dart$"
```An entire example project where `remove_from_coverage` is useful exists in the [`example` directory of the package](https://github.com/jack-r-warren/remove_from_coverage/tree/master/example).
## How it works
Code coverage reports are generated from an `lcov.info` file, which is generated by test coverage packages.In some cases, it might make sense to have some files excluded from code coverage reports, like generated or experimental files. Some generators of `lcov.info` files might support excluding files, but `remove_from_coverage` provides another route: after a `lcov.info` file has been generated, it can be manipulated to remove data relating to ignored files.
This means that `remove_from_coverage` is agnostic to both how the `lcov.info` file is generated or how it is used. It may be used for non-Dart projects, and it has been tested on both Linux and Windows.