diff options
Diffstat (limited to 'tests/run/coverage_cmd_src_layout.srctree')
-rw-r--r-- | tests/run/coverage_cmd_src_layout.srctree | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/run/coverage_cmd_src_layout.srctree b/tests/run/coverage_cmd_src_layout.srctree index 831ba489b..e79d3acba 100644 --- a/tests/run/coverage_cmd_src_layout.srctree +++ b/tests/run/coverage_cmd_src_layout.srctree @@ -133,20 +133,25 @@ def run_xml_report(): def run_html_report(): + from collections import defaultdict + stdout = run_coverage_command('html', '-d', 'html') - _parse_lines = re.compile( - r'<p[^>]* id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\'][^>]*' - r' class=["\'][^"\']*(?P<run>mis|run)[^"\']*["\']').findall + # coverage 6.1+ changed the order of the attributes => need to parse them separately + _parse_id = re.compile(r'id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\']').search + _parse_state = re.compile(r'class=["\'][^"\']*(?P<state>mis|run|exc)[^"\']*["\']').search files = {} for file_path in iglob('html/*.html'): with open(file_path) as f: page = f.read() - executed = set() - missing = set() - for line, has_run in _parse_lines(page): - (executed if has_run == 'run' else missing).add(int(line)) - files[file_path] = (executed, missing) + report = defaultdict(set) + for line in re.split(r'id=["\']source["\']', page)[-1].splitlines(): + lineno = _parse_id(line) + state = _parse_state(line) + if not lineno or not state: + continue + report[state.group('state')].add(int(lineno.group('id'))) + files[file_path] = (report['run'], report['mis']) executed, missing = [data for path, data in files.items() if 'trivial_module' in path][0] assert executed |