From 30233c00a6ff0ecaf57548feb232a93501c165c1 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 9 Mar 2016 14:29:56 -0600 Subject: [PATCH 1/3] parse sparse files correctly --- package.json | 2 +- source/index.js | 8 ++++---- test/assets/sample2.xml | 25 +++++++++++++++++++++++++ test/index.js | 16 ++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 test/assets/sample2.xml diff --git a/package.json b/package.json index 38eb3e8..866330e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cobertura-parse", - "version": "1.0.3", + "version": "1.0.4", "description": "Parse cobertura coverage to JSON, based on output from lcov-parse", "main": "source/index.js", "scripts": { diff --git a/source/index.js b/source/index.js index cd2636b..e06bfdd 100644 --- a/source/index.js +++ b/source/index.js @@ -33,9 +33,9 @@ var unpackage = function ( packages ) title: c.$.name, file: c.$.filename, functions: { - found: c.methods[ 0 ].method ? c.methods[ 0 ].method.length : 0, + found: c.methods && c.methods[ 0 ].method ? c.methods[ 0 ].method.length : 0, hit: 0, - details: !c.methods[ 0 ].method ? [] : c.methods[ 0 ].method.map( function ( m ) + details: !c.methods || !c.methods[ 0 ].method ? [] : c.methods[ 0 ].method.map( function ( m ) { return { name: m.$.name, @@ -45,9 +45,9 @@ var unpackage = function ( packages ) } ) }, lines: { - found: c.lines[ 0 ].line ? c.lines[ 0 ].line.length : 0, + found: c.lines && c.lines[ 0 ].line ? c.lines[ 0 ].line.length : 0, hit: 0, - details: !c.lines[ 0 ].line ? [] : c.lines[ 0 ].line.map( function ( l ) + details: !c.lines || !c.lines[ 0 ].line ? [] : c.lines[ 0 ].line.map( function ( l ) { return { line: Number( l.$.number ), diff --git a/test/assets/sample2.xml b/test/assets/sample2.xml new file mode 100644 index 0000000..31e0d66 --- /dev/null +++ b/test/assets/sample2.xml @@ -0,0 +1,25 @@ + + + + + /Users/bboland/src/vokal/Brandish-iOS + + + + + + + + + + + + + + + + + + + + diff --git a/test/index.js b/test/index.js index 7683af4..6a779a8 100644 --- a/test/index.js +++ b/test/index.js @@ -24,4 +24,20 @@ describe( "parseFile", function () done(); } ); } ); + + it( "should parse a sparse file", function ( done ) + { + parse.parseFile( path.join( __dirname, "assets", "sample2.xml" ), function ( err, result ) + { + assert.equal( err, null ); + assert.equal( result.length, 2 ); + assert.equal( result[ 0 ].functions.found, 0 ); + assert.equal( result[ 0 ].functions.hit, 0 ); + assert.equal( result[ 0 ].lines.found, 2 ); + assert.equal( result[ 0 ].lines.hit, 0 ); + assert.equal( result[ 0 ].functions.details.length, 0 ); + assert.equal( result[ 0 ].lines.details.length, 2 ); + done(); + } ); + } ); } ); From 0fcf85444b7f9a7813e2e8b432b2557a2adc7486 Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 9 Mar 2016 14:30:52 -0600 Subject: [PATCH 2/3] bah --- test/assets/sample2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/assets/sample2.xml b/test/assets/sample2.xml index 31e0d66..fe04cfb 100644 --- a/test/assets/sample2.xml +++ b/test/assets/sample2.xml @@ -2,7 +2,7 @@ - /Users/bboland/src/vokal/Brandish-iOS + ios From 7165e855af28502593af6e5f752fa8c32555d65f Mon Sep 17 00:00:00 2001 From: Jarrett Widman Date: Wed, 9 Mar 2016 14:37:37 -0600 Subject: [PATCH 3/3] build updates --- .travis.yml | 11 +++++++++++ run-build.sh | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 run-build.sh diff --git a/.travis.yml b/.travis.yml index 7ab627a..c476885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,14 @@ language: node_js node_js: - "0.10" - "0.12" + - "node" +env: + global: + - REPO_OWNER=vokal + - REPO_NAME=cobertura-parse +install: + - npm install -g istanbul + - npm install +script: + - chmod +x run-build.sh + - ./run-build.sh diff --git a/run-build.sh b/run-build.sh new file mode 100644 index 0000000..c5a85d8 --- /dev/null +++ b/run-build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +npm run testcover + +RESULT=$? + +COMMIT="${TRAVIS_COMMIT_RANGE##*...}" + +if [ $RESULT == 0 ]; then + echo "publish coverage for $COMMIT" + curl -F coverage=@coverage/lcov.info "https://cvr.vokal.io/coverage?owner=$REPO_OWNER&repo=$REPO_NAME&commit=$COMMIT&coveragetype=lcov" +else + curl -X POST "https://cvr.vokal.io/coverage/abort?owner=$REPO_OWNER&repo=$REPO_NAME&commit=$COMMIT" +fi + +exit $RESULT