Skip to content

Commit 89b541f

Browse files
committed
Run coverage in CI and add Coveralls badge
1 parent c1fe4f4 commit 89b541f

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

.travis.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ 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 lcov;
20-
export CXX='g++-4.8';
21-
export GYP_DEFINES='coverage=1';
19+
sudo apt-get -qq install gcc-4.8 g++-4.8 lcov;
20+
sudo rm /usr/bin/gcov /usr/bin/g++;
21+
sudo ln -s /usr/bin/gcov-4.8 /usr/bin/gcov;
22+
sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++;
23+
export CC="gcc-4.8";
24+
export CXX="g++-4.8";
25+
export GYP_DEFINES="coverage=1";
26+
export JOBS=4;
27+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90;
2228
fi
23-
- "export JOBS=4"
2429
- BUILD_ONLY=true npm install
2530
# This is a random private key used purely for testing.
2631
before_script:
@@ -41,7 +46,12 @@ branches:
4146
os:
4247
- linux
4348
- osx
44-
script: npm test
49+
script:
50+
- if [ $TRAVIS_OS_NAME == "linux" ] && [ $NODE_VERSION == "0.12" ]; then
51+
npm test && npm run cov && npm run coveralls;
52+
else
53+
npm test;
54+
fi
4555
notifications:
4656
slack:
4757
secure: KglNSqZiid9YudCwkPFDh+sZfW5BwFlM70y67E4peHwwlbbV1sSBPHcs74ZHP/lqgEZ4hMv4N2NI58oYFD5/1a+tKIQP1TkdIMuq4j2LXheuirA2HDcydOVrsC8kRx5XFGKdVRg/uyX2dlRHcOWFhxrS6yc6IxtxYWlRTD2SmEc=

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ NodeGit
99
<th>Linux</th>
1010
<th>OS X</th>
1111
<th>Windows</th>
12+
<th>Coverage</th>
1213
<th>Dependencies</th>
1314
</tr>
1415
</thead>
@@ -20,6 +21,9 @@ NodeGit
2021
<td align="center">
2122
<a href="https://ci.appveyor.com/project/timbranyen/nodegit"><img src="https://ci.appveyor.com/api/projects/status/e5a5q75l9yfhnfv2?svg=true"></a>
2223
</td>
24+
<td align="center">
25+
<a href="https://coveralls.io/r/nodegit/nodegit"><img src="https://coveralls.io/repos/nodegit/nodegit/badge.svg" alt="Coverage Status"></a>
26+
</td>
2327
<td align="center">
2428
<a href="https://david-dm.org/nodegit/nodegit"><img src="https://david-dm.org/nodegit/nodegit.svg"></a>
2529
</td>

generate/templates/templates/binding.gyp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"<(module_root_dir)/vendor/libgit2.gyp:libgit2"
1010
],
1111

12+
"variables": {
13+
"coverage%": 0
14+
},
15+
1216
"sources": [
1317
"src/nodegit.cc",
1418
"src/wrapper.cc",
@@ -32,6 +36,19 @@
3236
],
3337

3438
"conditions": [
39+
[
40+
"coverage==1", {
41+
"cflags": [
42+
"-ftest-coverage",
43+
"-fprofile-arcs"
44+
],
45+
"link_settings": {
46+
"libraries": [
47+
"-lgcov"
48+
]
49+
},
50+
}
51+
],
3552
[
3653
"OS=='mac'", {
3754
"xcode_settings": {

lifecycleScripts/install.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function build() {
8686

8787
var opts = {
8888
cwd: ".",
89-
maxBuffer: Number.MAX_VALUE
89+
maxBuffer: Number.MAX_VALUE,
90+
env: process.env
9091
};
9192

9293
var prefix = "";

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
},
6464
"devDependencies": {
6565
"combyne": "^0.6.5",
66+
"coveralls": "^2.11.2",
6667
"istanbul": "^0.3.5",
6768
"js-beautify": "^1.5.4",
6869
"jshint": "^2.6.0",
@@ -82,6 +83,7 @@
8283
},
8384
"scripts": {
8485
"lint": "jshint lib test/tests examples lifecycleScripts",
86+
"coveralls": "cat ./test/coverage/merged.lcov | coveralls",
8587
"cppcov": "mkdir -p test/coverage/cpp && lcov --capture --directory build/Release/obj.target/nodegit/src --output-file test/coverage/cpp/lcov.info",
8688
"mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
8789
"cov": "npm run cppcov && npm run mergecov",

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var fork = require("child_process").fork;
22
var path = require("path");
33

44
var bin = "./node_modules/.bin/istanbul";
5-
var cov = "cover --report=lcov _mocha --".split(" ");
5+
var cov = "cover --report=lcov --dir=test/coverage/js _mocha --".split(" ");
66

77
if (process.platform === 'win32') {
88
bin = "./node_modules/mocha/bin/mocha";

0 commit comments

Comments
 (0)