Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
efed079f
Commit
efed079f
authored
Feb 21, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverage: try harder to find .pxi files, avoid some unnecessary work
parent
15eb19bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
Cython/Coverage.py
Cython/Coverage.py
+24
-10
No files found.
Cython/Coverage.py
View file @
efed079f
...
@@ -27,6 +27,16 @@ def _find_c_source(base_path):
...
@@ -27,6 +27,16 @@ def _find_c_source(base_path):
return
c_file
return
c_file
def
_find_dep_file_path
(
main_file
,
file_path
):
abs_path
=
os
.
path
.
abspath
(
file_path
)
if
file_path
.
endswith
(
'.pxi'
)
and
not
os
.
path
.
exists
(
abs_path
):
# include files are looked up relative to the main source file
pxi_file_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
main_file
),
file_path
)
if
os
.
path
.
exists
(
pxi_file_path
):
abs_path
=
os
.
path
.
abspath
(
pxi_file_path
)
return
abs_path
class
Plugin
(
CoveragePlugin
):
class
Plugin
(
CoveragePlugin
):
_c_files_map
=
None
_c_files_map
=
None
...
@@ -37,6 +47,8 @@ class Plugin(CoveragePlugin):
...
@@ -37,6 +47,8 @@ class Plugin(CoveragePlugin):
"""
"""
Try to find a C source file for a file path found by the tracer.
Try to find a C source file for a file path found by the tracer.
"""
"""
if
filename
.
startswith
(
'<'
)
or
filename
.
startswith
(
'memory:'
):
return
None
c_file
=
py_file
=
None
c_file
=
py_file
=
None
filename
=
os
.
path
.
abspath
(
filename
)
filename
=
os
.
path
.
abspath
(
filename
)
if
self
.
_c_files_map
and
filename
in
self
.
_c_files_map
:
if
self
.
_c_files_map
and
filename
in
self
.
_c_files_map
:
...
@@ -54,6 +66,7 @@ class Plugin(CoveragePlugin):
...
@@ -54,6 +66,7 @@ class Plugin(CoveragePlugin):
# name than the .c file (which prevents us from finding the
# name than the .c file (which prevents us from finding the
# .c file)
# .c file)
self
.
_parse_lines
(
c_file
,
filename
)
self
.
_parse_lines
(
c_file
,
filename
)
return
CythonModuleTracer
(
filename
,
py_file
,
c_file
,
self
.
_c_files_map
)
return
CythonModuleTracer
(
filename
,
py_file
,
c_file
,
self
.
_c_files_map
)
def
file_reporter
(
self
,
filename
):
def
file_reporter
(
self
,
filename
):
...
@@ -148,7 +161,8 @@ class Plugin(CoveragePlugin):
...
@@ -148,7 +161,8 @@ class Plugin(CoveragePlugin):
self
.
_c_files_map
=
{}
self
.
_c_files_map
=
{}
for
filename
in
filenames
:
for
filename
in
filenames
:
self
.
_c_files_map
[
os
.
path
.
abspath
(
filename
)]
=
(
abs_path
=
_find_dep_file_path
(
c_file
,
filename
)
self
.
_c_files_map
[
abs_path
]
=
(
c_file
,
filename
,
code_lines
[
filename
],
excluded_lines
[
filename
])
c_file
,
filename
,
code_lines
[
filename
],
excluded_lines
[
filename
])
if
sourcefile
not
in
self
.
_c_files_map
:
if
sourcefile
not
in
self
.
_c_files_map
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment