지정된 줄이나 파일을 커버리지 보고서에서 제거하여 lcov.info 커버리지 파일을 수정하도록 설계된 명령줄 도구입니다. 생성되거나 보일러플레이트 코드와 같은 특정 코드 섹션을 제외함으로써 개발자가 테스트 커버리지 데이터를 정제하고 더 정확하고 의미 있는 커버리지 메트릭을 확보할 수 있도록 도와줍니다. CI/CD 파이프라인에서는 깔끔하고 집중적인 커버리지 보고서가 필수적이므로 이 도구는 특히 유용합니다. macOS, Windows 및 Linux에서 실행 가능하여 다양한 개발 환경에서 접근성이 뛰어납니다.
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.
Remove files with paths matching given PATTERNs from the lcov.info FILE
-f, --file=<FILE> the target lcov.info file to manipulate
-r, --remove=<PATTERN> 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
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.