Commit 15eb19bf authored by Stefan Behnel's avatar Stefan Behnel

teach Cython.Coverage about "pkg.mod.pyx" file name patterns

parent b42255e4
...@@ -11,10 +11,22 @@ from collections import defaultdict ...@@ -11,10 +11,22 @@ from collections import defaultdict
from coverage.plugin import CoveragePlugin, FileTracer, FileReporter # requires coverage.py 4.0+ from coverage.plugin import CoveragePlugin, FileTracer, FileReporter # requires coverage.py 4.0+
from coverage.files import FileLocator # requires coverage.py 4.0+ from coverage.files import FileLocator # requires coverage.py 4.0+
from .Utils import find_root_package_dir
from . import __version__ from . import __version__
def _find_c_source(base_path):
if os.path.exists(base_path + '.c'):
c_file = base_path + '.c'
elif os.path.exists(base_path + '.cpp'):
c_file = base_path + '.cpp'
else:
c_file = None
return c_file
class Plugin(CoveragePlugin): class Plugin(CoveragePlugin):
_c_files_map = None _c_files_map = None
...@@ -71,14 +83,14 @@ class Plugin(CoveragePlugin): ...@@ -71,14 +83,14 @@ class Plugin(CoveragePlugin):
# none of our business # none of our business
return None, None return None, None
if ext in ('.c', '.cpp'): c_file = filename if ext in ('.c', '.cpp') else _find_c_source(basename)
c_file = filename if c_file is None:
elif os.path.exists(basename + '.c'): # a module "pkg/mod.so" can have a source file "pkg/pkg.mod.c"
c_file = basename + '.c' package_root = find_root_package_dir.uncached(filename)
elif os.path.exists(basename + '.cpp'): package_path = os.path.relpath(basename, package_root).split(os.path.sep)
c_file = basename + '.cpp' if len(package_path) > 1:
else: test_basepath = os.path.join(os.path.dirname(filename), '.'.join(package_path))
c_file = None c_file = _find_c_source(test_basepath)
py_source_file = None py_source_file = None
if c_file: if c_file:
......
...@@ -21,6 +21,7 @@ def cached_function(f): ...@@ -21,6 +21,7 @@ def cached_function(f):
if res is uncomputed: if res is uncomputed:
res = cache[args] = f(*args) res = cache[args] = f(*args)
return res return res
wrapper.uncached = f
return wrapper return wrapper
def cached_method(f): def cached_method(f):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment