[Pkg-javascript-commits] [node-coveralls] 17/332: using lcov-parse lib. version bump 2.0.5

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:33 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 5b2ed846c142ccdcd28b309a6b8bd76b2d0b96be
Author: cainus <gregg at caines.ca>
Date:   Thu Mar 28 11:33:45 2013 -0700

    using lcov-parse lib.  version bump 2.0.5
---
 bin/coveralls.js               |  18 +++---
 lib/convertLcovToCoveralls.js  |  26 ++++----
 lib/parser.js                  | 131 -----------------------------------------
 package.json                   |   5 +-
 test/convertLcovToCoveralls.js |  20 ++++---
 5 files changed, 40 insertions(+), 160 deletions(-)

diff --git a/bin/coveralls.js b/bin/coveralls.js
index 273f95e..288b451 100644
--- a/bin/coveralls.js
+++ b/bin/coveralls.js
@@ -19,16 +19,20 @@ var inputToCoveralls = function(input){
 	console.log(input);
 	var libDir = process.argv[2] || '';
 
-	var postData = convertLcovToCoveralls(input, libDir);
-  sendToCoveralls(postData, function(err, response, body){
+	convertLcovToCoveralls(input, libDir, function(err, postData){
     if (err){
       throw err;
     }
-    if (response.statusCode >= 400){
-      throw "Bad response: " + response.statusCode + " " + body;
-    }
-    console.log(response.statusCode);
-    console.log(body);
+    sendToCoveralls(postData, function(err, response, body){
+      if (err){
+        throw err;
+      }
+      if (response.statusCode >= 400){
+        throw "Bad response: " + response.statusCode + " " + body;
+      }
+      console.log(response.statusCode);
+      console.log(body);
+    });
   });
 
 };
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 14d637e..d05056d 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -1,6 +1,6 @@
 var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 'unknown';
 var fs = require('fs');
-var lcovParse = require('./parser');
+var lcovParse = require('lcov-parse');
 var path = require('path');
 
 var detailsToCoverage = function(length, details){
@@ -21,21 +21,23 @@ var convertLcovFileObject = function(file, filepath){
            coverage : coverage	};
 };
 
-var convertLcovToCoveralls = function(input, filepath){
+var convertLcovToCoveralls = function(input, filepath, cb){
   console.log("in: ", filepath);
   if (filepath[0] !== '/'){
     filepath = path.join(process.cwd(), filepath);
   }
-  var parsed = lcovParse(input);
-	var postJson = {
-    service_job_id : TRAVIS_JOB_ID,
-    service_name : "travis-ci",
-		source_files : []
-	};
-	parsed.forEach(function(file){
-		postJson.source_files.push(convertLcovFileObject(file, filepath));
-	});
-	return postJson;
+  lcovParse(input, function(err, parsed){
+    if (err){  return cb(err); }
+    var postJson = {
+      service_job_id : TRAVIS_JOB_ID,
+      service_name : "travis-ci",
+      source_files : []
+    };
+    parsed.forEach(function(file){
+      postJson.source_files.push(convertLcovFileObject(file, filepath));
+    });
+    return cb(null, postJson);
+  });
 };
 
 module.exports = convertLcovToCoveralls;
diff --git a/lib/parser.js b/lib/parser.js
deleted file mode 100644
index 83b2c3d..0000000
--- a/lib/parser.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-Software License Agreement (BSD License)
-
-Copyright (c) 2012, Dav Glass <davglass at gmail.com>.
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms, with or without modification, are
-permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above
-  copyright notice, this list of conditions and the
-  following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the
-  following disclaimer in the documentation and/or other
-  materials provided with the distribution.
-
-* The name of Dav Glass may not be used to endorse or promote products
-  derived from this software without specific prior
-  written permission of Dav Glass.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-var lcovParse = function(str) {
-    var data = [], item = {};
-
-    str = str.split('\n');
-    str.forEach(function(line) {
-        line = line.trim();
-
-        var parts = line.split(':'), lines, fn;
-
-        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: []
-                    };
-                }
-                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: []
-                    };
-                }
-                fn = parts[1].split(',');
-                item.functions.details.push({
-                    name: fn[1],
-                    line: Number(fn[0])
-                });
-                break;
-            case 'FNDA':
-                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;
-            case 'BRDA':
-                if (!item.branches) {
-                    item.branches = {
-                        hit: 0,
-                        found: 0,
-                        details: []
-                    };
-                }
-                fn = parts[1].split(',');
-                item.branches.details.push({
-                    line: Number(fn[0]),
-                    block: Number(fn[1]),
-                    branch: Number(fn[2]),
-                    taken: ((fn[3] === '-') ? 0 : Number(fn[3]))
-                });
-                break;
-            case 'BRF':
-                item.branches.found = Number(parts[1]);
-                break;
-            case 'BRH':
-                item.branches.hit = Number(parts[1]);
-                break;
-        }
-
-        if (line.indexOf('end_of_record') > -1) {
-            data.push(item);
-            item = {};
-        }
-    });
-    return data;
-};
-
-module.exports = lcovParse;
diff --git a/package.json b/package.json
index 19245cd..a7d3ba5 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
       "name": "coveralls",
       "description" : "takes json-cov output into stdin and POSTs to coveralls.io",
       "keywords" : ["coverage", "coveralls"], 
-      "version": "2.0.4",
+      "version": "2.0.5",
       "bugs": {
        "url": "https://github.com/cainus/node-coveralls/issues"
       },
@@ -20,7 +20,8 @@
         } 
       ],
       "dependencies": {
-          "request" : "2.16.2"
+          "request" : "2.16.2",
+          "lcov-parse" : "0.0.3"
       },
       "devDependencies" : {
           "mocha" : "1.8.1",
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js
index bbe5f09..6cf9521 100644
--- a/test/convertLcovToCoveralls.js
+++ b/test/convertLcovToCoveralls.js
@@ -8,11 +8,13 @@ describe("convertLcovToCoveralls", function(){
     var path = __dirname + "/../fixtures/onefile.lcov";
     var input = fs.readFileSync(path, "utf8");
     var libpath = __dirname + "/../fixtures/lib";
-    var output = convertLcovToCoveralls(input, libpath);
-    output.source_files[0].name.should.equal("index.js");
-    output.source_files[0].source.split("\n").length.should.equal(225);
-    output.source_files[0].coverage[54].should.equal(0);
-    output.source_files[0].coverage[60].should.equal(0);
+    convertLcovToCoveralls(input, libpath, function(err, output){
+      should.not.exist(err);
+      output.source_files[0].name.should.equal("index.js");
+      output.source_files[0].source.split("\n").length.should.equal(225);
+      output.source_files[0].coverage[54].should.equal(0);
+      output.source_files[0].coverage[60].should.equal(0);
+    });
   });
 
   it ("should work with a relative path as well", function(){
@@ -20,8 +22,10 @@ describe("convertLcovToCoveralls", function(){
     var path = __dirname + "/../fixtures/onefile.lcov";
     var input = fs.readFileSync(path, "utf8");
     var libpath = "fixtures/lib";
-    var output = convertLcovToCoveralls(input, libpath);
-    output.source_files[0].name.should.equal("index.js");
-    output.source_files[0].source.split("\n").length.should.equal(225);
+    convertLcovToCoveralls(input, libpath, function(err, output){
+      should.not.exist(err);
+      output.source_files[0].name.should.equal("index.js");
+      output.source_files[0].source.split("\n").length.should.equal(225);
+    });
   });
 });

-- 
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