Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 2x 8x 2x 2x 284x 284x 272x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 2x 2x | import { extname, basename } from 'path';
import { CoverageAccumulator } from './accumulator';
import type { BaseParser, Results } from './base';
export class LcovParser implements BaseParser<string> {
globs = ['*.lcov', 'lcov.info', '**/*/lcov.info', '**/*/*.lcov'];
matches(path: string, contents: string) {
return basename(path) === 'lcov.info' || extname(path) === '.lcov' ? contents : false;
}
public parse(contents: string): Results {
const accumulator = new CoverageAccumulator();
for (const line of contents.split('\n')) {
const [type, value] = line.split(':');
if (type === undefined || value === undefined) continue;
switch (type) {
case 'LF': {
accumulator.total('lines', value);
break;
}
case 'LH': {
accumulator.hit('lines', value);
break;
}
case 'FNF': {
accumulator.total('functions', value);
break;
}
case 'FNH': {
accumulator.hit('functions', value);
break;
}
case 'BRF': {
accumulator.total('branches', value);
break;
}
case 'BRH': {
accumulator.hit('branches', value);
break;
}
}
}
return accumulator.toResults();
}
}
export const lcov = new LcovParser();
|