lcov_tracefile 0.0.2 copy "lcov_tracefile: ^0.0.2" to clipboard
lcov_tracefile: ^0.0.2 copied to clipboard

Dependence-free model and parser for lcov tracefiles. Parses the coverage data from lcov files line by line and produces the model.

lcov_tracefile #

A simple library to read and parse code coverage data from tracefiles.

Example:

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%');
  }
}

2
likes
160
points
896
downloads

Publisher

verified publisherkarapetov.com

Weekly Downloads

Dependence-free model and parser for lcov tracefiles. Parses the coverage data from lcov files line by line and produces the model.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on lcov_tracefile