[Pkg-javascript-commits] [node-coveralls] 267/332: Ignore files that do not exist in convertLcovToCoveralls

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:54:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 993332233a2f02695a769e2c17c0d593a96b14c9
Author: Arjan Singh <arjan.singh at dollarshaveclub.com>
Date:   Wed Apr 6 21:36:30 2016 -0700

    Ignore files that do not exist in convertLcovToCoveralls
---
 lib/convertLcovToCoveralls.js  |  5 ++++-
 test/convertLcovToCoveralls.js | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index ca2c2c0..e925343 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -61,7 +61,10 @@ var convertLcovToCoveralls = function(input, options, cb){
       postJson.service_pull_request = options.service_pull_request;
     }
     parsed.forEach(function(file){
-      postJson.source_files.push(convertLcovFileObject(file, filepath));
+      var currentFilePath = path.resolve(filepath, file.file);
+      if (fs.existsSync(currentFilePath)) {
+        postJson.source_files.push(convertLcovFileObject(file, filepath));
+      }
     });
     return cb(null, postJson);
   });
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js
index 82ffdc8..bb4d8a6 100644
--- a/test/convertLcovToCoveralls.js
+++ b/test/convertLcovToCoveralls.js
@@ -75,12 +75,46 @@ describe("convertLcovToCoveralls", function(){
       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].name.should.equal(path.join("svgo", "config.js"));
       done();
     });
   });
+
+  it ("should ignore files that do not exists", 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 false; };
+
+    convertLcovToCoveralls(input, {filepath: libpath}, function(err, output){
+      fs.readFileSync = originalReadFileSync;
+      fs.existsSync = originalExistsSync;
+
+      should.not.exist(err);
+      output.source_files.should.be.empty;
+      done();
+    });
+  });
+
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list