lcov-parse
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -6,6 +6,5 @@ var fs = require('fs'), | ||
var walkFile = function(str, cb) { | ||
var data = [], item = {}; | ||
var data = [], item; | ||
str = str.split('\n'); | ||
str.forEach(function(line) { | ||
[ 'end_of_record' ].concat(str.split('\n')).forEach(function(line) { | ||
line = line.trim(); | ||
@@ -35,9 +34,2 @@ | ||
case 'DA': | ||
if (!item.lines) { | ||
item.lines = { | ||
found: 0, | ||
hit: 0, | ||
details: [] | ||
}; | ||
} | ||
lines = parts[1].split(','); | ||
@@ -50,9 +42,2 @@ item.lines.details.push({ | ||
case 'FN': | ||
if (!item.functions) { | ||
item.functions = { | ||
hit: 0, | ||
found: 0, | ||
details: [] | ||
}; | ||
} | ||
fn = parts[1].split(','); | ||
@@ -74,9 +59,2 @@ item.functions.details.push({ | ||
case 'BRDA': | ||
if (!item.branches) { | ||
item.branches = { | ||
hit: 0, | ||
found: 0, | ||
details: [] | ||
}; | ||
} | ||
fn = parts[1].split(','); | ||
@@ -100,5 +78,24 @@ item.branches.details.push({ | ||
data.push(item); | ||
item = {}; | ||
item = { | ||
lines: { | ||
found: 0, | ||
hit: 0, | ||
details: [] | ||
}, | ||
functions: { | ||
hit: 0, | ||
found: 0, | ||
details: [] | ||
}, | ||
branches: { | ||
hit: 0, | ||
found: 0, | ||
details: [] | ||
} | ||
}; | ||
} | ||
}); | ||
data.shift(); | ||
if (data.length) { | ||
@@ -105,0 +102,0 @@ cb(null, data); |
{ | ||
"name": "lcov-parse", | ||
"description": "Parse lcov results files and return JSON", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": { "url" : "http://github.com/davglass/lcov-parse/issues" }, |
@@ -43,8 +43,8 @@ var vows = require('vows'), | ||
}, | ||
'should contain 2 keys': function(err, data) { | ||
assert.equal(data.length, 2); | ||
'should contain 3 keys': function(err, data) { | ||
assert.equal(data.length, 3); | ||
}, | ||
'first key should have 4 properties': function(err, data) { | ||
var d = data[0]; | ||
assert.deepEqual(Object.keys(d), [ 'title', 'file', 'functions', 'lines' ]); | ||
'first key should have 5 properties': function(err, data) { | ||
var keys = Object.keys(data[0]); | ||
assert.deepEqual(keys.sort(), [ 'branches', 'file', 'functions', 'lines', 'title' ]) | ||
}, | ||
@@ -54,2 +54,3 @@ 'verify test titles': function(err, data) { | ||
assert.equal(data[1].title, 'Test #2'); | ||
assert.equal(data[2].title, 'Test #3'); | ||
}, | ||
@@ -59,2 +60,3 @@ 'verify test files': function(err, data) { | ||
assert.equal(data[1].file, 'anim-easing/anim-easing-coverage.js'); | ||
assert.equal(data[2].file, 'javascript/common.js'); | ||
}, | ||
@@ -66,2 +68,4 @@ 'verify number of functions': function(err, data) { | ||
assert.equal(data[1].functions.hit, 17); | ||
assert.equal(data[2].functions.found, 2); | ||
assert.equal(data[2].functions.hit, 2); | ||
}, | ||
@@ -73,2 +77,5 @@ 'verify number of branches': function(err, data) { | ||
assert.equal(data[1].branches.details[data[1].branches.details.length - 1].taken, 0); | ||
assert.equal(data[2].branches.found, 0); | ||
assert.equal(data[2].branches.hit, 0); | ||
assert.deepEqual(data[2].branches.details, []); | ||
}, | ||
@@ -78,2 +85,3 @@ 'verify function details': function(err, data) { | ||
assert.equal(data[1].functions.details.length, 17); | ||
assert.equal(data[2].functions.details.length, 2); | ||
assert.deepEqual(data[0].functions.details[0], { name: '(anonymous 1)', line: 7, hit: 6 }); | ||
@@ -87,2 +95,4 @@ assert.deepEqual(data[0].functions.details[11], { name: '_start', line: 475, hit: 231 }); | ||
assert.deepEqual(data[2].functions.details[1], { name: 'javascript', line: 3, hit: 2 }); | ||
}, | ||
@@ -98,2 +108,3 @@ 'verify number of lines': function(err, data) { | ||
assert.equal(data[1].lines.details.length, 76); | ||
assert.equal(data[2].lines.details.length, 6); | ||
assert.deepEqual(data[0].lines.details[0], { line: 7, hit: 6 }); | ||
@@ -104,2 +115,4 @@ assert.deepEqual(data[0].lines.details[10], { line: 91, hit: 6 }); | ||
assert.deepEqual(data[1].lines.details[64], { line: 313, hit: 51 }); | ||
assert.deepEqual(data[2].lines.details[2], { line: 3, hit: 19 }); | ||
}, | ||
@@ -106,0 +119,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32695
13
210