aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarc Knaup <[email protected]>2014-03-14 12:02:02 +0100
committerMarc Knaup <[email protected]>2014-03-14 12:02:02 +0100
commit913039d9323c94467c853cac985455d5941c454f (patch)
tree853de7b1d6366b4212e5ff3144f78c1f470c347b /test
parent0ba53be012ff78282ad39c0863e56fd460005f25 (diff)
downloadnode-coveralls-913039d9323c94467c853cac985455d5941c454f.tar.xz
node-coveralls-913039d9323c94467c853cac985455d5941c454f.zip
convertLcovToCoveralls should convert absolute source paths to relative paths in output.
Diffstat (limited to 'test')
-rw-r--r--test/convertLcovToCoveralls.js38
1 files changed, 32 insertions, 6 deletions
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js
index 2e07a87..0e3b9da 100644
--- a/test/convertLcovToCoveralls.js
+++ b/test/convertLcovToCoveralls.js
@@ -3,13 +3,14 @@ var getOptions = require('../index').getOptions;
var should = require('should');
var fs = require('fs');
var logger = require('../lib/logger');
+var path = require('path');
logger = require('log-driver')({level : false});
describe("convertLcovToCoveralls", function(){
it ("should convert a simple lcov file", function(done){
process.env.TRAVIS_JOB_ID = -1;
- var path = __dirname + "/../fixtures/onefile.lcov";
- var input = fs.readFileSync(path, "utf8");
+ var lcovpath = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(lcovpath, "utf8");
var libpath = __dirname + "/../fixtures/lib";
convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){
should.not.exist(err);
@@ -30,8 +31,8 @@ describe("convertLcovToCoveralls", function(){
process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN";
getOptions(function(err, options){
- var path = __dirname + "/../fixtures/onefile.lcov";
- var input = fs.readFileSync(path, "utf8");
+ var lcovpath = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(lcovpath, "utf8");
var libpath = "fixtures/lib";
options.filepath = libpath;
convertLcovToCoveralls(input, options, function(err, output){
@@ -43,8 +44,8 @@ describe("convertLcovToCoveralls", function(){
});
it ("should work with a relative path as well", function(done){
process.env.TRAVIS_JOB_ID = -1;
- var path = __dirname + "/../fixtures/onefile.lcov";
- var input = fs.readFileSync(path, "utf8");
+ var lcovpath = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(lcovpath, "utf8");
var libpath = "fixtures/lib";
convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){
should.not.exist(err);
@@ -53,4 +54,29 @@ describe("convertLcovToCoveralls", function(){
done();
});
});
+
+ it ("should convert absolute input paths to relative", 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);
+ }
+
+ convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){
+ fs.readFileSync = originalReadFileSync;
+
+ should.not.exist(err);
+ output.source_files[0].name.should.equal(path.join("svgo", "config.js"));
+ done();
+ });
+ });
});