summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/run/coverage_cmd.srctree16
-rw-r--r--tests/run/coverage_cmd_src_layout.srctree21
2 files changed, 23 insertions, 14 deletions
diff --git a/tests/run/coverage_cmd.srctree b/tests/run/coverage_cmd.srctree
index 70408409c..0f80c586e 100644
--- a/tests/run/coverage_cmd.srctree
+++ b/tests/run/coverage_cmd.srctree
@@ -222,17 +222,21 @@ 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|exc)[^"\']*["\']').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()
report = defaultdict(set)
- for line, state in _parse_lines(page):
- report[state].add(int(line))
+ 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
for filename, report in files.items():
@@ -241,7 +245,7 @@ def run_html_report():
executed = report["run"]
missing = report["mis"]
excluded = report["exc"]
- assert executed
+ assert executed, (filename, report)
assert 5 in executed, executed
assert 6 in executed, executed
assert 7 in executed, executed
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