Skip to content

Commit cc99b48

Browse files
committed
wip: add coverage testing
1 parent edf6be7 commit cc99b48

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
plugins = Cython.Coverage

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ __pycache__
1111
MANIFEST
1212
.eggs
1313
.local
14+
*.egg-info
15+
.coverage

bin/activate

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export C_INCLUDE_PATH=$(pwd)/.local/include
2+
export LIBRARY_PATH=$(pwd)/.local/lib
3+
export LD_LIBRARY_PATH=$(pwd)/.local/lib
4+
export PYTHONPATH=$(pwd)/src

bin/coverage.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#
3+
# Note: cython's Cython/Coverage.py fails for pyx files that are included in
4+
# other pyx files. A patch to the file is needed:
5+
#
6+
# --- Coverage.py.backup 2022-12-09 17:36:35.387690467 +0000
7+
# +++ Coverage.py 2022-12-09 17:08:06.282516837 +0000
8+
# @@ -172,7 +172,9 @@ class Plugin(CoveragePlugin):
9+
# else:
10+
# c_file, _ = self._find_source_files(filename)
11+
# if not c_file:
12+
# - return None
13+
# + c_file = os.path.join(os.path.dirname(filename), 'pyflint.c')
14+
# + if not os.path.exists(c_file):
15+
# + return None
16+
# rel_file_path, code = self._read_source_lines(c_file, filename)
17+
# if code is None:
18+
# return None # no source found
19+
#
20+
#
21+
22+
set -o errexit
23+
24+
source bin/activate
25+
26+
python setup.py build_ext --inplace
27+
28+
29+
coverage run test/test.py
30+
31+
coverage report -m
32+
coverage html

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from distutils.core import setup
55
from distutils.extension import Extension
66
from Cython.Distutils import build_ext
7+
from Cython.Build import cythonize
78
from numpy.distutils.system_info import default_include_dirs, default_lib_dirs
89

910
from distutils.sysconfig import get_config_vars
@@ -24,7 +25,9 @@
2425
"flint._flint", ["src/flint/pyflint.pyx"],
2526
libraries=libraries,
2627
library_dirs=default_lib_dirs,
27-
include_dirs=default_include_dirs)
28+
include_dirs=default_include_dirs,
29+
define_macros=[('CYTHON_TRACE', 1)],
30+
)
2831
]
2932

3033
for e in ext_modules:
@@ -33,7 +36,7 @@
3336
setup(
3437
name='python-flint',
3538
cmdclass={'build_ext': build_ext},
36-
ext_modules=ext_modules,
39+
ext_modules=cythonize(ext_modules, compiler_directives={'linetrace': True, 'language_level':2}),
3740
packages=['flint'],
3841
package_dir={'': 'src'},
3942
description='Bindings for FLINT and Arb',

0 commit comments

Comments
 (0)