https://github.com/f3ath/lcov-tracefile
A simple library to read and parse code coverage data from lcov tracefiles.
https://github.com/f3ath/lcov-tracefile
Last synced: 4 months ago
JSON representation
A simple library to read and parse code coverage data from lcov tracefiles.
- Host: GitHub
- URL: https://github.com/f3ath/lcov-tracefile
- Owner: f3ath
- License: mit
- Created: 2022-09-08T02:23:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-21T02:46:17.000Z (almost 2 years ago)
- Last Synced: 2025-06-14T05:03:04.165Z (7 months ago)
- Language: Dart
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lcov_tracefile
A simple library to read and parse code coverage data from tracefiles.
Example:
```dart
import 'dart:io';
import 'package:lcov_tracefile/lcov_tracefile.dart';
/// This code reads the "lcov.info" and prints line coverage for each source file.
void main() {
final scriptDir = Directory(Platform.script.path).parent.path;
final fileName = '$scriptDir${Platform.pathSeparator}lcov.info';
// Read the file from the disk.
final lines = File(fileName).readAsLinesSync();
// Build the tracefile model
final tracefile = readTracefile(lines);
for (final source in tracefile.sources) {
final name = source.name;
final linesFound = source.lines.found ?? 0;
final linesHit = source.lines.hit ?? 0;
final lineCoverage =
linesFound == 0 ? 0 : (100 * linesHit / linesFound).round();
print('File $name, line coverage $lineCoverage%');
}
}
```