Skip to content

Commit b91e5d2

Browse files
tiranencukou
authored andcommitted
Add GCOV / LCOV C coverage support
#7
1 parent 52077e8 commit b91e5d2

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ addons:
1818
- ldap-utils
1919
- slapd
2020

21+
env:
22+
- WITH_GCOV=1
23+
2124
install:
2225
- pip install "pip>=7.1.0"
2326
- pip install tox-travis tox codecov coverage
2427

2528
script: tox
2629

2730
after_success:
31+
# gather Python coverage
2832
- python -m coverage combine
33+
# send Python and GCOV coverage
2934
- codecov

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
LCOV_INFO=build/lcov.info
2+
LCOV_REPORT=build/lcov_report
3+
LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \
4+
--title "python-ldap LCOV report"
5+
16
.NOTPARALLEL:
27

38
.PHONY: all
@@ -9,3 +14,28 @@ clean:
914
rm -f .coverage .coverage.*
1015
find . -name '*.py[co]' -or -name '*.so*' -or -name '*.dylib' -delete
1116
find . -depth -name __pycache__ -exec rm -rf {} \;
17+
18+
# LCOV report (measuring test coverage for C code)
19+
.PHONY: lcov-clean lcov-coverage lcov-report lcov-open lcov
20+
lcov-clean:
21+
rm -rf $(LCOV_INFO) $(LCOV_REPORT)
22+
find build -name '*.gc??' -delete
23+
24+
lcov-coverage:
25+
WITH_GCOV=1 tox -e py27,py36
26+
27+
$(LCOV_INFO):
28+
lcov --capture --directory build --output-file $(LCOV_INFO)
29+
30+
$(LCOV_REPORT): $(LCOV_INFO)
31+
genhtml --output-directory $(LCOV_REPORT) \
32+
$(LCOV_REPORT_OPTIONS) $(LCOV_INFO)
33+
34+
lcov-report: $(LCOV_REPORT)
35+
36+
lcov-open: $(LCOV_REPORT)
37+
xdg-open $(LCOV_REPORT)/index.html
38+
39+
lcov: lcov-clean
40+
$(MAKE) lcov-coverage
41+
$(MAKE) lcov-report

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class OpenLDAP2:
3434
extra_link_args = []
3535
extra_objects = []
3636
libs = ['ldap', 'lber']
37-
defines = [ ]
37+
defines = []
3838
extra_files = []
3939

4040
LDAP_CLASS = OpenLDAP2
@@ -55,6 +55,14 @@ class OpenLDAP2:
5555
origfileslist = origfiles.split(',')
5656
LDAP_CLASS.extra_files[i]=(destdir, origfileslist)
5757

58+
if os.environ.get('WITH_GCOV'):
59+
# Insrumentation for measuring code coverage
60+
LDAP_CLASS.extra_compile_args.extend(
61+
['-O0', '-pg', '-fprofile-arcs', '-ftest-coverage']
62+
)
63+
LDAP_CLASS.extra_link_args.append('-pg')
64+
LDAP_CLASS.libs.append('gcov')
65+
5866
#-- Let distutils/setuptools do the rest
5967
name = 'python-ldap'
6068

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ deps =
1313
pyasn1
1414
pyasn1_modules
1515
commands = {envpython} -m coverage run --parallel setup.py test
16+
passenv = WITH_GCOV
1617

1718
[testenv:coverage-report]
1819
deps = coverage

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy