Commit be99a19f authored by Stefan Behnel's avatar Stefan Behnel

Repair coverage tests to make them work with coverage 6.1, which changed the...

Repair coverage tests to make them work with coverage 6.1, which changed the HTML output format that the tests parse.
parent 798ad9f8
...@@ -176,23 +176,33 @@ def run_xml_report(): ...@@ -176,23 +176,33 @@ def run_xml_report():
def run_html_report(): def run_html_report():
from collections import defaultdict
stdout = run_coverage_command('html', '-d', 'html') stdout = run_coverage_command('html', '-d', 'html')
_parse_lines = re.compile( # coverage 6.1+ changed the order of the attributes => need to parse them separately
r'<p[^>]* id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\'][^>]*' _parse_id = re.compile(r'id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\']').search
r' class=["\'][^"\']*(?P<run>mis|run)[^"\']*["\']').findall _parse_state = re.compile(r'class=["\'][^"\']*(?P<state>mis|run|exc)[^"\']*["\']').search
files = {} files = {}
for file_path in iglob('html/*.html'): for file_path in iglob('html/*.html'):
with open(file_path) as f: with open(file_path) as f:
page = f.read() page = f.read()
executed = set() report = defaultdict(set)
missing = set() for line in re.split(r'id=["\']source["\']', page)[-1].splitlines():
for line, has_run in _parse_lines(page): lineno = _parse_id(line)
(executed if has_run == 'run' else missing).add(int(line)) state = _parse_state(line)
files[file_path] = (executed, missing) if not lineno or not state:
continue
executed, missing = [data for path, data in files.items() if 'coverage_test_pyx' in path][0] report[state.group('state')].add(int(lineno.group('id')))
assert executed files[file_path] = report
for filename, report in files.items():
if "coverage_test_pyx" not in filename:
continue
executed = report["run"]
missing = report["mis"]
excluded = report["exc"]
assert executed, (filename, report)
assert 5 in executed, executed assert 5 in executed, executed
assert 6 in executed, executed assert 6 in executed, executed
assert 7 in executed, executed assert 7 in executed, executed
......
...@@ -133,20 +133,25 @@ def run_xml_report(): ...@@ -133,20 +133,25 @@ def run_xml_report():
def run_html_report(): def run_html_report():
from collections import defaultdict
stdout = run_coverage_command('html', '-d', 'html') stdout = run_coverage_command('html', '-d', 'html')
_parse_lines = re.compile( # coverage 6.1+ changed the order of the attributes => need to parse them separately
r'<p[^>]* id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\'][^>]*' _parse_id = re.compile(r'id=["\'][^0-9"\']*(?P<id>[0-9]+)[^0-9"\']*["\']').search
r' class=["\'][^"\']*(?P<run>mis|run)[^"\']*["\']').findall _parse_state = re.compile(r'class=["\'][^"\']*(?P<state>mis|run|exc)[^"\']*["\']').search
files = {} files = {}
for file_path in iglob('html/*.html'): for file_path in iglob('html/*.html'):
with open(file_path) as f: with open(file_path) as f:
page = f.read() page = f.read()
executed = set() report = defaultdict(set)
missing = set() for line in re.split(r'id=["\']source["\']', page)[-1].splitlines():
for line, has_run in _parse_lines(page): lineno = _parse_id(line)
(executed if has_run == 'run' else missing).add(int(line)) state = _parse_state(line)
files[file_path] = (executed, missing) 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] executed, missing = [data for path, data in files.items() if 'trivial_module' in path][0]
assert executed assert executed
......
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