Skip to content

Commit c1fe4f4

Browse files
committed
Adds in C++ code coverage and joined JS
This commit adds in CPP code coverage via GCC and GCOV. That lcov data is then joined to the JavaScript istanbul output and then generated into unified test/coverage/report and test/merged.cov reports.
1 parent f2b007d commit c1fe4f4

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ before_install:
1616
- if [ $TRAVIS_OS_NAME == "linux" ]; then
1717
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
1818
sudo apt-get -qq update;
19-
sudo apt-get -qq install g++-4.8;
19+
sudo apt-get -qq install g++-4.8 lcov;
2020
export CXX='g++-4.8';
21+
export GYP_DEFINES='coverage=1';
2122
fi
2223
- "export JOBS=4"
2324
- BUILD_ONLY=true npm install

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"istanbul": "^0.3.5",
6767
"js-beautify": "^1.5.4",
6868
"jshint": "^2.6.0",
69+
"lcov-result-merger": "^1.0.2",
6970
"lodash": "^3.1.0",
7071
"mocha": "~2.1.0",
7172
"nan": "^1.7.0",
@@ -81,10 +82,12 @@
8182
},
8283
"scripts": {
8384
"lint": "jshint lib test/tests examples lifecycleScripts",
84-
"cov": "node --expose-gc test",
85+
"cppcov": "mkdir -p test/coverage/cpp && lcov --capture --directory build/Release/obj.target/nodegit/src --output-file test/coverage/cpp/lcov.info",
86+
"mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
87+
"cov": "npm run cppcov && npm run mergecov",
8588
"mocha": "mocha test/runner test/tests",
8689
"mochaDebug": "mocha --debug-brk test/runner test/tests",
87-
"test": "npm run lint && npm run cov",
90+
"test": "npm run lint && node --expose-gc test",
8891
"generateJson": "node generate/scripts/generateJson",
8992
"generateNativeCode": "node generate/scripts/generateNativeCode",
9093
"generateMissingTests": "node generate/scripts/generateMissingTests",

test/index.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
var fork = require("child_process").fork;
22
var path = require("path");
33

4-
var args = [
5-
"cover",
6-
process.platform != "win32" ?
7-
"_mocha" :
8-
"../node_modules/mocha/bin/_mocha",
9-
"--",
10-
"runner",
11-
"tests",
12-
"--report=lcov",
4+
var bin = "./node_modules/.bin/istanbul";
5+
var cov = "cover --report=lcov _mocha --".split(" ");
6+
7+
if (process.platform === 'win32') {
8+
bin = "./node_modules/mocha/bin/mocha";
9+
cov = [];
10+
}
11+
12+
var args = cov.concat([
13+
"test/runner",
14+
"test/tests",
1315
"--expose-gc"
14-
];
16+
]);
1517

16-
fork("../node_modules/istanbul/lib/cli.js", args, {
17-
cwd: __dirname
18-
}).on("close", function(code) {
19-
process.exit(code);
20-
});
18+
fork(bin, args, { cwd: path.join(__dirname, "../") }).on("close", process.exit);

0 commit comments

Comments
 (0)