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 1 commit
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
Next Next commit
Add GCOV / LCOV C coverage support
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
tiran authored and encukou committed Nov 25, 2017
commit 94777ca10b74f8576f847838501df9c8b45501b7
33 changes: 25 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
language: python

python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
# Note: when updating Python versions, also change setup.py and tox.ini

sudo: false

cache: pip
Expand All @@ -18,12 +10,37 @@ addons:
- ldap-utils
- slapd

matrix:
include:
- python: 2.7
env:
- TOXENV=py27
- WITH_GCOV=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is WITH_GCOV necessary here? It's specified in tox.ini.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, passenv only passes through existing variables, right? In that case I guess it's fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tox.ini has passenv = WITH_GCOV. It does not set WITH_GCOV but let tox pass the env vars through. By default tox unsets most env vars.

- python: 3.3
env:
- TOXENV=py33
- WITH_GCOV=1
- python: 3.4
env:
- TOXENV=py34
- WITH_GCOV=1
- python: 3.5
env:
- TOXENV=py35
- WITH_GCOV=1
- python: 3.6
env:
- TOXENV=py36
- 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
9 changes: 8 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,13 @@ class OpenLDAP2:
origfileslist = origfiles.split(',')
LDAP_CLASS.extra_files[i]=(destdir, origfileslist)

if os.environ.get('WITH_GCOV'):
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