Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d09db57
Showing
6 changed files
with
586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
node_modules | |||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
language: node_js | |||
node_js: | |||
- 0.4 | |||
- 0.6 | |||
- 0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
var fs = require('fs'), | |||
path = require('path'), | |||
|
|||
exists = fs.exists || path.exists; | |||
|
|||
var results = {}; | |||
|
|||
var walkFile = function(str, cb) { | |||
var data = []; | |||
str = str.split('\n'); | |||
var item = {}; | |||
str.forEach(function(line) { | |||
line = line.trim(); | |||
var parts = line.split(':'); | |||
switch (parts[0].toUpperCase()) { | |||
case 'TN': | |||
item.title = parts[1].trim(); | |||
break; | |||
case 'SF': | |||
item.file = parts[1].trim(); | |||
break; | |||
case 'FNF': | |||
item.functions.found = Number(parts[1].trim()); | |||
break; | |||
case 'FNH': | |||
item.functions.hit = Number(parts[1].trim()); | |||
break; | |||
case 'LF': | |||
item.lines.found = Number(parts[1].trim()); | |||
break; | |||
case 'LH': | |||
item.lines.hit = Number(parts[1].trim()); | |||
break; | |||
case 'DA': | |||
if (!item.lines) { | |||
item.lines = { | |||
found: 0, | |||
hit: 0, | |||
details: [] | |||
}; | |||
} | |||
var lines = parts[1].split(','); | |||
item.lines.details.push({ | |||
line: Number(lines[0]), | |||
hit: Number(lines[1]) | |||
}); | |||
break; | |||
case 'FN': | |||
if (!item.functions) { | |||
item.functions = { | |||
hit: 0, | |||
found: 0, | |||
details: [] | |||
}; | |||
} | |||
var fn = parts[1].split(','); | |||
item.functions.details.push({ | |||
name: fn[1], | |||
line: Number(fn[0]) | |||
}); | |||
break; | |||
case 'FNDA': | |||
var fn = parts[1].split(','); | |||
item.functions.details.some(function(i, k) { | |||
if (i.name === fn[1] && i.hit === undefined) { | |||
item.functions.details[k].hit = Number(fn[0]); | |||
return true; | |||
} | |||
}); | |||
break; | |||
} | |||
|
|||
if (line.indexOf('end_of_record') > -1) { | |||
data.push(item); | |||
item = {}; | |||
} | |||
}); | |||
cb(null, data); | |||
}; | |||
|
|||
var parse = function(file, cb) { | |||
|
|||
exists(file, function(x) { | |||
if (!x) { | |||
cb("Failed to find file: " + file); | |||
return; | |||
} | |||
fs.readFile(file, 'utf8', function(err, str) { | |||
walkFile(str, cb); | |||
}); | |||
}); | |||
|
|||
}; | |||
|
|||
|
|||
module.exports = parse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
{ | |||
"name": "lcov-parse", | |||
"description": "Parse lcov results files and return JSON", | |||
"version": "0.0.1", | |||
"author": "Dav Glass <davglass@gmail.com>", | |||
"bugs": { "url" : "http://github.com/davglass/lcov-parse/issues" }, | |||
"main": "./lib/index", | |||
"tags": [ | |||
"lcov", | |||
"json", | |||
"coverage", | |||
"parser" | |||
], | |||
"devDependencies": { | |||
"vows": "*" | |||
}, | |||
"scripts": { | |||
"test": "./node_modules/.bin/vows ./tests/*.js" | |||
}, | |||
"licenses":[ | |||
{ | |||
"type" : "BSD" | |||
} | |||
], | |||
"repository": { | |||
"type":"git", | |||
"url":"http://github.com/davglass/lcov-parse.git" | |||
} | |||
} |
Oops, something went wrong.