Skip to content

Add GCOV / LCOV C coverage support #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ addons:
- ldap-utils
- slapd

env:
- WITH_GCOV=1

install:
- pip install "pip>=7.1.0"
- pip install tox-travis tox codecov coverage

script: tox

after_success:
# gather Python coverage
- python -m coverage combine
# send Python and GCOV coverage
- codecov
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
LCOV_INFO=build/lcov.info
LCOV_REPORT=build/lcov_report
LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \
--title "python-ldap LCOV report"

.NOTPARALLEL:

.PHONY: all
Expand All @@ -9,3 +14,28 @@ clean:
rm -f .coverage .coverage.*
find . -name '*.py[co]' -or -name '*.so*' -or -name '*.dylib' -delete
find . -depth -name __pycache__ -exec rm -rf {} \;

# LCOV report (measuring test coverage for C code)
.PHONY: lcov-clean lcov-coverage lcov-report lcov-open lcov
lcov-clean:
rm -rf $(LCOV_INFO) $(LCOV_REPORT)
find build -name '*.gc??' -delete

lcov-coverage:
WITH_GCOV=1 tox -e py27,py36

$(LCOV_INFO):
lcov --capture --directory build --output-file $(LCOV_INFO)

$(LCOV_REPORT): $(LCOV_INFO)
genhtml --output-directory $(LCOV_REPORT) \
$(LCOV_REPORT_OPTIONS) $(LCOV_INFO)

lcov-report: $(LCOV_REPORT)

lcov-open: $(LCOV_REPORT)
xdg-open $(LCOV_REPORT)/index.html

lcov: lcov-clean
$(MAKE) lcov-coverage
$(MAKE) lcov-report
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OpenLDAP2:
extra_link_args = []
extra_objects = []
libs = ['ldap', 'lber']
defines = [ ]
defines = []
extra_files = []

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

if os.environ.get('WITH_GCOV'):
# Insrumentation for measuring code coverage
LDAP_CLASS.extra_compile_args.extend(
['-O0', '-pg', '-fprofile-arcs', '-ftest-coverage']
)
LDAP_CLASS.extra_link_args.append('-pg')
LDAP_CLASS.libs.append('gcov')

#-- Let distutils/setuptools do the rest
name = 'python-ldap'

Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ deps =
pyasn1
pyasn1_modules
commands = {envpython} -m coverage run --parallel setup.py test
passenv = WITH_GCOV

[testenv:coverage-report]
deps = coverage
Expand Down
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