Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented ability to exclude code from coverage. #460

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
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
31 changes: 28 additions & 3 deletions src/blanket.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,28 @@ var parseAndModify = (inBrowser ? window.falafel : require("falafel"));
__blanket = window.blanket.noConflict();
}

var shouldIgnore = false;

var checkLeadingComments = function(node) {
var comments = node.leadingComments,
comment;

if (!comments) {
return;
}

for (var i = 0, length = comments.length; i < length; i++) {
comment = comments[i];

if (comment.value === "blanketjs:ignore true") {
shouldIgnore = true;
}
else if (comment.value === "blanketjs:ignore false") {
shouldIgnore = false;
}
}
};

_blanket = {

noConflict: function() {
Expand Down Expand Up @@ -131,7 +153,8 @@ var parseAndModify = (inBrowser ? window.falafel : require("falafel"));

var instrumented = parseAndModify(inFile, {
loc: true,
comment: true
comment: true,
attachComment: true
}, _blanket._addTracking(inFileName));

instrumented = _blanket._trackingSetup(inFileName, sourceArray) + instrumented;
Expand Down Expand Up @@ -273,8 +296,10 @@ var parseAndModify = (inBrowser ? window.falafel : require("falafel"));
}

if (node.loc && node.loc.start) {
node.update(covVar + "['" + filename + "'][" + node.loc.start.line + "]++;\n" + node.source());
_blanket._trackingArraySetup.push(node.loc.start.line);
if (!shouldIgnore) {
node.update(covVar + "['" + filename + "'][" + node.loc.start.line + "]++;\n" + node.source());
_blanket._trackingArraySetup.push(node.loc.start.line);
}
} else {
//I don't think we can handle a node with no location
throw new Error("The instrumenter encountered a node with no location: " + Object.keys(node));
Expand Down