Comparing version
@@ -15,2 +15,12 @@ var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 'unknown'; | ||
var detailsToBranches = function(details){ | ||
var branches = []; | ||
details.forEach(function(obj){ | ||
['line','block','branch','taken'].forEach(function(key){ | ||
branches.push(obj[key] || 0); | ||
}); | ||
}); | ||
return branches; | ||
}; | ||
var convertLcovFileObject = function(file, filepath){ | ||
@@ -22,5 +32,7 @@ var rootpath = filepath; | ||
var coverage = detailsToCoverage(lines.length, file.lines.details); | ||
var branches = detailsToBranches(file.branches.details); | ||
return { name : path.relative(rootpath, path.resolve(rootpath, file.file)).split( path.sep ).join( "/" ), | ||
source : source, | ||
coverage : coverage }; | ||
coverage : coverage, | ||
branches : branches }; | ||
}; | ||
@@ -32,3 +44,3 @@ | ||
var matches = regex.exec(file); | ||
return matches[matches.length-1]; | ||
return matches[matches.length-1]; | ||
} | ||
@@ -35,0 +47,0 @@ |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "2.11.16", | ||
"version": "2.12.0", | ||
"bugs": { | ||
@@ -11,0 +11,0 @@ "url": "https://github.com/nickmerwin/node-coveralls/issues" |
@@ -91,2 +91,31 @@ var convertLcovToCoveralls = require('../index').convertLcovToCoveralls; | ||
it ("should handle branch coverage data", function(done){ | ||
process.env.TRAVIS_JOB_ID = -1; | ||
var lcovpath = __dirname + "/../fixtures/istanbul.lcov"; | ||
var input = fs.readFileSync(lcovpath, "utf8"); | ||
var libpath = "/Users/deepsweet/Dropbox/projects/svgo/lib"; | ||
var sourcepath = path.resolve(libpath, "svgo/config.js"); | ||
var originalReadFileSync = fs.readFileSync; | ||
fs.readFileSync = function(filepath) { | ||
if (filepath === sourcepath) { | ||
return ''; | ||
} | ||
return originalReadFileSync.apply(fs, arguments); | ||
}; | ||
var originalExistsSync = fs.existsSync; | ||
fs.existsSync = function () { return true; }; | ||
convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){ | ||
fs.readFileSync = originalReadFileSync; | ||
fs.existsSync = originalExistsSync; | ||
should.not.exist(err); | ||
output.source_files[0].branches.slice(0,8).should.eql([18,1,0,85,18,1,1,2]); | ||
done(); | ||
}); | ||
}); | ||
it ("should ignore files that do not exists", function(done){ | ||
@@ -93,0 +122,0 @@ delete process.env.TRAVIS; |
70372
1.86%1641
2.12%153
0.66%