Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/internal/test_runner/reporter/lcov.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const { relative } = require('path');
const Transform = require('internal/streams/transform');
const { SafeSet } = require('internal/primordials');

// This reporter is based on the LCOV format, as described here:
// https://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
Expand Down Expand Up @@ -68,7 +69,20 @@ class LcovReporter extends Transform {
// Taken is either '-' if the basic block containing the branch was
// never executed or a number indicating how often that branch was
// taken.
// Build set of ignored line numbers from coverage data.
// A line is ignored if it appears with ignore=true in the file.lines array.
const ignoredLineSet = new SafeSet();
for (let k = 0; k < file.lines.length; k++) {
if (file.lines[k].ignore) {
ignoredLineSet.add(file.lines[k].line);
}
}

for (let j = 0; j < file.branches.length; j++) {
// Skip branches that point to ignored lines.
if (ignoredLineSet.has(file.branches[j].line)) {
continue;
}
lcov += `BRDA:${file.branches[j].line},${j},0,${file.branches[j].count}\n`;
}

Expand Down Expand Up @@ -104,4 +118,4 @@ class LcovReporter extends Transform {
}
}

module.exports = LcovReporter;
module.exports = LcovReporter;
Loading