Update code coverage configuration to include cython code.

This commit is contained in:
Chris PeBenito 2018-03-05 20:33:02 -05:00
parent a82a7fcc84
commit 4a98b8315b
4 changed files with 15 additions and 13 deletions

View File

@ -1,8 +1,7 @@
#coverage.py configuration
[run]
source = setools
# This is SWIG generated:
omit = setools/policyrep/qpol.py
plugins = Cython.Coverage
[report]
exclude_lines =

View File

@ -16,7 +16,6 @@
# License along with SETools. If not, see
# <http://www.gnu.org/licenses/>.
#
#cython: language_level=3, c_string_type=str, c_string_encoding=ascii
from cpython.exc cimport PyErr_SetFromErrnoWithFilename
from cpython.mem cimport PyMem_Malloc, PyMem_Free

View File

@ -34,7 +34,7 @@ class QtHelpCommand(Command):
os.rename('qhc/apol.qhc', 'setoolsgui/apol/apol.qhc')
os.rename('qhc/apol.qch', 'setoolsgui/apol/apol.qch')
# Library linkage
lib_dirs = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
include_dirs = []
@ -46,6 +46,11 @@ if sys.platform.startswith('darwin'):
else:
macros=[]
# Code coverage. Enable this to get coverage in the cython code.
enable_coverage = bool(os.environ.get("SETOOLS_COVERAGE", False))
if enable_coverage:
macros.append(("CYTHON_TRACE", 1))
ext_py_mods = [Extension('setools.policyrep.libpolicyrep', ['setools/policyrep/libpolicyrep.pyx'],
include_dirs=include_dirs,
libraries=['selinux', 'sepol'],
@ -81,7 +86,11 @@ setup(name='setools',
scripts=['apol', 'sediff', 'seinfo', 'seinfoflow', 'sesearch', 'sedta'],
data_files=[(join(sys.prefix, 'share/man/man1'), glob.glob("man/*.1"))],
package_data={'': ['*.ui', '*.qhc', '*.qch'], 'setools': ['perm_map']},
ext_modules=cythonize(ext_py_mods, include_path=['setools/policyrep']),
ext_modules=cythonize(ext_py_mods, include_path=['setools/policyrep'],
compiler_directives={"language_level": 3,
"c_string_type": "str",
"c_string_encoding": "ascii",
"linetrace": enable_coverage}),
test_suite='tests',
license='GPLv2+, LGPLv2.1+',
classifiers=[

11
tox.ini
View File

@ -1,12 +1,6 @@
[tox]
minversion = 1.4
envlist = py34, py35, py36
# Using site packages is not optimal,
# but libselinux bindings are not
# available via PyPI.
# Any issues this hides should be found
# by Travis CI, as that env is minimal.
sitepackages = True
[pep8]
exclude = qpol.py
@ -19,12 +13,13 @@ commands = pep8 --version
pep8 setools/ setoolsgui/ tests/ seinfo seinfoflow sedta sesearch sediff --statistics
[testenv:coverage]
setenv = SETOOLS_COVERAGE = 1
deps = networkx==2.0
coverage
coverage>=4.0
cython>=0.27
commands = coverage --version
coverage erase
coverage run setup.py test
coverage run setup.py test -q
coverage report
[testenv:lint]