Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ optimized = [
"rust-pyspec-glue>=0.0.9,<0.1.0",
"ethash>=1.1.0,<2",
]
coverage = [
"slipcover",
]

[tool.setuptools.dynamic]
version = { attr = "ethereum.__version__" }
Expand Down
38 changes: 38 additions & 0 deletions src/ethereum_spec_tools/get_baseline_cov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import xml.etree.ElementTree as ET
import json


def parse_coverage_xml(xml_path):
tree = ET.parse(xml_path)
root = tree.getroot()
result = {}

for cls in root.findall(".//class"):
filename = cls.attrib["filename"]
lines = cls.find("lines")
if lines is None:
continue
covered = []
missing = []
for line in lines.findall("line"):
num = int(line.attrib["number"])
hits = int(line.attrib["hits"])
if hits > 0:
covered.append(num)
else:
missing.append(num)
result[filename] = {
"covered_lines": covered,
"missing_lines": missing
}
return result


if __name__ == "__main__":
xml_path = ".tox/coverage.xml"
out_file = "baseline_coverage.json"

data = parse_coverage_xml(xml_path)
with open(out_file, "w") as f:
json.dump(data, f, indent=2)
print(f"Wrote {out_file}")
Loading