Commit f00cd893 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.29.x'

parents a5d9314c 86904478
...@@ -191,6 +191,7 @@ class Plugin(CoveragePlugin): ...@@ -191,6 +191,7 @@ class Plugin(CoveragePlugin):
match_source_path_line = re.compile(r' */[*] +"(.*)":([0-9]+)$').match match_source_path_line = re.compile(r' */[*] +"(.*)":([0-9]+)$').match
match_current_code_line = re.compile(r' *[*] (.*) # <<<<<<+$').match match_current_code_line = re.compile(r' *[*] (.*) # <<<<<<+$').match
match_comment_end = re.compile(r' *[*]/$').match match_comment_end = re.compile(r' *[*]/$').match
match_trace_line = re.compile(r' *__Pyx_TraceLine\(([0-9]+),').match
not_executable = re.compile( not_executable = re.compile(
r'\s*c(?:type)?def\s+' r'\s*c(?:type)?def\s+'
r'(?:(?:public|external)\s+)?' r'(?:(?:public|external)\s+)?'
...@@ -199,15 +200,20 @@ class Plugin(CoveragePlugin): ...@@ -199,15 +200,20 @@ class Plugin(CoveragePlugin):
).match ).match
code_lines = defaultdict(dict) code_lines = defaultdict(dict)
filenames = set() executable_lines = defaultdict(set)
current_filename = None
with open(c_file) as lines: with open(c_file) as lines:
lines = iter(lines) lines = iter(lines)
for line in lines: for line in lines:
match = match_source_path_line(line) match = match_source_path_line(line)
if not match: if not match:
if '__Pyx_TraceLine(' in line and current_filename is not None:
trace_line = match_trace_line(line)
if trace_line:
executable_lines[current_filename].add(int(trace_line.group(1)))
continue continue
filename, lineno = match.groups() filename, lineno = match.groups()
filenames.add(filename) current_filename = filename
lineno = int(lineno) lineno = int(lineno)
for comment_line in lines: for comment_line in lines:
match = match_current_code_line(comment_line) match = match_current_code_line(comment_line)
...@@ -221,6 +227,12 @@ class Plugin(CoveragePlugin): ...@@ -221,6 +227,12 @@ class Plugin(CoveragePlugin):
# unexpected comment format - false positive? # unexpected comment format - false positive?
break break
# Remove lines that generated code but are not traceable.
for filename, lines in code_lines.items():
dead_lines = set(lines).difference(executable_lines.get(filename, ()))
for lineno in dead_lines:
del lines[lineno]
self._parsed_c_files[c_file] = code_lines self._parsed_c_files[c_file] = code_lines
if self._c_files_map is None: if self._c_files_map is None:
......
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