aboutsummaryrefslogtreecommitdiff
path: root/lib/parser.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parser.js')
-rw-r--r--lib/parser.js131
1 files changed, 0 insertions, 131 deletions
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 <[email protected]>.
-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;