-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
46 lines (36 loc) · 1.33 KB
/
Copy pathcheck.py
File metadata and controls
46 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from __future__ import annotations
import pathlib
import json
import sys
from typing import Any
def check_reports(reports: list[dict[str, Any]]) -> list[str]:
if not reports:
return []
errors = []
all_group_counts = sorted({r["total_groups"] for r in reports})
if len(all_group_counts) != 1:
errors.append(
f"Different amount of groups specified between runs: {', '.join(map(str, all_group_counts))}"
)
if not all(r["collected"] == reports[0]["collected"] for r in reports):
errors.append("Collected different items between runs")
else:
all_selected = [item for report in reports for item in report["selected"]]
if len(all_selected) != len(reports[0]["collected"]):
errors.append("Items missing during collection")
return errors
def check(report_dir: pathlib.Path) -> list[str]:
reports: list[dict[str, Any]] = [
json.loads(f.read_bytes())
for f in report_dir.glob("pytest_cdist_report_*.json")
]
return check_reports(reports)
def main() -> None:
errors = check(pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else "."))
if errors:
print("Errors during pytest-cdist check")
for error in errors:
print(error)
quit(1)
else:
print("Pytest-cdist check found no issues")